https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91745

            Bug ID: 91745
           Summary: Documentation for __builtin_speculation_safe_value()
                    doesn't compile
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andrew.cooper3 at citrix dot com
  Target Milestone: ---

https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fspeculation_005fsafe_005fvalue-1

The 3rd code sample in the documentation talks about how to transform the code
when element 0 of the array isn't safe to speculatively access.

https://godbolt.org/z/98LNs8

Unfortunately, it doesn't compile, citing:

[x86-64 gcc 9.2 #1] error: both arguments must be compatible

Replacing NULL with (int *)0 does allow the sample to compile.

I'm not wel- versed enough in the C spec to comment on whether NULL and (int
*)0 are compatible or not, but the intention of the documentation is clearly
that NULL should be acceptable in this circumstance.

Is this a documentation bug, or a diagnostics bug?

Reply via email to