What does the content about unsafe.Poiner in the compiler section in Go 1.15 release notes?

122 views
Skip to first unread message

T L

unread,
Jun 12, 2020, 8:28:18 AM6/12/20
to golang-nuts

Package unsafe's safety rules allow converting an unsafe.Pointer into uintptr when calling certain functions. Previously, in some cases, the compiler allowed multiple chained conversions (for example, syscall.Syscall(…, uintptr(uintptr(ptr)), …)). The compiler now requires exactly one conversion. Code that used multiple conversions should be updated to satisfy the safety rules.


I didn't find the difference from Go 1.14.

Axel Wagner

unread,
Jun 12, 2020, 12:47:03 PM6/12/20
to T L, golang-nuts
AIUI: The safety rules haven't changed. How the compiler interprets them has. Previously, it interpreted them so as to allow multiple chained conversions. Now it doesn't.

On Fri, Jun 12, 2020 at 2:28 PM T L <tapi...@gmail.com> wrote:

Package unsafe's safety rules allow converting an unsafe.Pointer into uintptr when calling certain functions. Previously, in some cases, the compiler allowed multiple chained conversions (for example, syscall.Syscall(…, uintptr(uintptr(ptr)), …)). The compiler now requires exactly one conversion. Code that used multiple conversions should be updated to satisfy the safety rules.


I didn't find the difference from Go 1.14.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0f62c576-a1f9-467e-b99c-42f01edaa452o%40googlegroups.com.

Ian Lance Taylor

unread,
Jun 12, 2020, 12:55:24 PM6/12/20
to Axel Wagner, T L, golang-nuts
On Fri, Jun 12, 2020 at 9:46 AM 'Axel Wagner' via golang-nuts
<golan...@googlegroups.com> wrote:
>
> AIUI: The safety rules haven't changed. How the compiler interprets them has. Previously, it interpreted them so as to allow multiple chained conversions. Now it doesn't.

Yes.

Ian


> On Fri, Jun 12, 2020 at 2:28 PM T L <tapi...@gmail.com> wrote:
>>
>>
>> Package unsafe's safety rules allow converting an unsafe.Pointer into uintptr when calling certain functions. Previously, in some cases, the compiler allowed multiple chained conversions (for example, syscall.Syscall(…, uintptr(uintptr(ptr)), …)). The compiler now requires exactly one conversion. Code that used multiple conversions should be updated to satisfy the safety rules.
>>
>>
>> I didn't find the difference from Go 1.14.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0f62c576-a1f9-467e-b99c-42f01edaa452o%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfGcW8%2BBC2g2JAcwJyQKxiPDxF%3DfJG%3DJJVxx7PHSk3_xkQ%40mail.gmail.com.

T L

unread,
Jun 12, 2020, 12:56:12 PM6/12/20
to golang-nuts
Is "uintptr(uintptr(ptr))" a typo? Or are there any other multiple chained conversions examples?

On Friday, June 12, 2020 at 12:47:03 PM UTC-4, Axel Wagner wrote:
AIUI: The safety rules haven't changed. How the compiler interprets them has. Previously, it interpreted them so as to allow multiple chained conversions. Now it doesn't.

On Fri, Jun 12, 2020 at 2:28 PM T L <tapi...@gmail.com> wrote:

Package unsafe's safety rules allow converting an unsafe.Pointer into uintptr when calling certain functions. Previously, in some cases, the compiler allowed multiple chained conversions (for example, syscall.Syscall(…, uintptr(uintptr(ptr)), …)). The compiler now requires exactly one conversion. Code that used multiple conversions should be updated to satisfy the safety rules.


I didn't find the difference from Go 1.14.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.

Ian Lance Taylor

unread,
Jun 12, 2020, 1:02:30 PM6/12/20
to T L, golang-nuts
On Fri, Jun 12, 2020 at 9:56 AM T L <tapi...@gmail.com> wrote:
>
> Is "uintptr(uintptr(ptr))" a typo? Or are there any other multiple chained conversions examples?

That is not a typo. That is the case that worked in 1.14 and does not
work in 1.15.

Ian
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/6139806c-8937-4f71-97a0-eae51fecdb8co%40googlegroups.com.

T L

unread,
Jun 12, 2020, 1:08:26 PM6/12/20
to golang-nuts


On Friday, June 12, 2020 at 1:02:30 PM UTC-4, Ian Lance Taylor wrote:
On Fri, Jun 12, 2020 at 9:56 AM T L <tapi...@gmail.com> wrote:
>
> Is "uintptr(uintptr(ptr))" a typo? Or are there any other multiple chained conversions examples?

That is not a typo.  That is the case that worked in 1.14 and does not
work in 1.15.

Ian


So "uintptr(unsafe.Pointer(ptr))" also doesn't work now?
 

> On Friday, June 12, 2020 at 12:47:03 PM UTC-4, Axel Wagner wrote:
>>
>> AIUI: The safety rules haven't changed. How the compiler interprets them has. Previously, it interpreted them so as to allow multiple chained conversions. Now it doesn't.
>>
>> On Fri, Jun 12, 2020 at 2:28 PM T L <tapi...@gmail.com> wrote:
>>>
>>>
>>> Package unsafe's safety rules allow converting an unsafe.Pointer into uintptr when calling certain functions. Previously, in some cases, the compiler allowed multiple chained conversions (for example, syscall.Syscall(…, uintptr(uintptr(ptr)), …)). The compiler now requires exactly one conversion. Code that used multiple conversions should be updated to satisfy the safety rules.
>>>
>>>
>>> I didn't find the difference from Go 1.14.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0f62c576-a1f9-467e-b99c-42f01edaa452o%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.

Ian Lance Taylor

unread,
Jun 12, 2020, 1:33:32 PM6/12/20
to T L, golang-nuts
On Fri, Jun 12, 2020 at 10:08 AM T L <tapi...@gmail.com> wrote:
>
> On Friday, June 12, 2020 at 1:02:30 PM UTC-4, Ian Lance Taylor wrote:
>>
>> On Fri, Jun 12, 2020 at 9:56 AM T L <tapi...@gmail.com> wrote:
>> >
>> > Is "uintptr(uintptr(ptr))" a typo? Or are there any other multiple chained conversions examples?
>>
>> That is not a typo. That is the case that worked in 1.14 and does not
>> work in 1.15.
>>
>> Ian
>>
>
> So "uintptr(unsafe.Pointer(ptr))" also doesn't work now?

No, that continues to work as before. Nobody has said anything about that case.

Again: the case that no longer works is uintptr(uintptr(ptr)).

Ian


>> > On Friday, June 12, 2020 at 12:47:03 PM UTC-4, Axel Wagner wrote:
>> >>
>> >> AIUI: The safety rules haven't changed. How the compiler interprets them has. Previously, it interpreted them so as to allow multiple chained conversions. Now it doesn't.
>> >>
>> >> On Fri, Jun 12, 2020 at 2:28 PM T L <tapi...@gmail.com> wrote:
>> >>>
>> >>>
>> >>> Package unsafe's safety rules allow converting an unsafe.Pointer into uintptr when calling certain functions. Previously, in some cases, the compiler allowed multiple chained conversions (for example, syscall.Syscall(…, uintptr(uintptr(ptr)), …)). The compiler now requires exactly one conversion. Code that used multiple conversions should be updated to satisfy the safety rules.
>> >>>
>> >>>
>> >>> I didn't find the difference from Go 1.14.
>> >>>
>> >>> --
>> >>> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
>> >>> To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
>> >>> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0f62c576-a1f9-467e-b99c-42f01edaa452o%40googlegroups.com.
>> >
>> > --
>> > You received this message because you are subscribed to the Google Groups "golang-nuts" group.
>> > To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
>> > To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/6139806c-8937-4f71-97a0-eae51fecdb8co%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/12d0fa65-0364-4da1-bf9a-dd6b4cef39e3o%40googlegroups.com.

T L

unread,
Jun 12, 2020, 10:34:28 PM6/12/20
to golang-nuts


On Friday, June 12, 2020 at 1:33:32 PM UTC-4, Ian Lance Taylor wrote:
On Fri, Jun 12, 2020 at 10:08 AM T L <tapi...@gmail.com> wrote:
>
> On Friday, June 12, 2020 at 1:02:30 PM UTC-4, Ian Lance Taylor wrote:
>>
>> On Fri, Jun 12, 2020 at 9:56 AM T L <tapi...@gmail.com> wrote:
>> >
>> > Is "uintptr(uintptr(ptr))" a typo? Or are there any other multiple chained conversions examples?
>>
>> That is not a typo.  That is the case that worked in 1.14 and does not
>> work in 1.15.
>>
>> Ian
>>
>
> So "uintptr(unsafe.Pointer(ptr))" also doesn't work now?

No, that continues to work as before.  Nobody has said anything about that case.

Again: the case that no longer works is uintptr(uintptr(ptr)).

Ian


Get it. Thanks both for the explanations.
 

>> > On Friday, June 12, 2020 at 12:47:03 PM UTC-4, Axel Wagner wrote:
>> >>
>> >> AIUI: The safety rules haven't changed. How the compiler interprets them has. Previously, it interpreted them so as to allow multiple chained conversions. Now it doesn't.
>> >>
>> >> On Fri, Jun 12, 2020 at 2:28 PM T L <tapi...@gmail.com> wrote:
>> >>>
>> >>>
>> >>> Package unsafe's safety rules allow converting an unsafe.Pointer into uintptr when calling certain functions. Previously, in some cases, the compiler allowed multiple chained conversions (for example, syscall.Syscall(…, uintptr(uintptr(ptr)), …)). The compiler now requires exactly one conversion. Code that used multiple conversions should be updated to satisfy the safety rules.
>> >>>
>> >>>
>> >>> I didn't find the difference from Go 1.14.
>> >>>
>> >>> --
>> >>> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
>> >>> To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
>> >>> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/0f62c576-a1f9-467e-b99c-42f01edaa452o%40googlegroups.com.
>> >
>> > --
>> > You received this message because you are subscribed to the Google Groups "golang-nuts" group.
>> > To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
>> > To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/6139806c-8937-4f71-97a0-eae51fecdb8co%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages