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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Bruno Haible from comment #4)
> Why? This code is accessing read-only memory near the address of the 'tramp'
> function. Why would it need 'volatile' when doing so? (I don't claim that
> this is portable ISO C code; it's  doing a low-level thing. But C is meant
> to be used for low-level things.)

Because it is accessing before the begining of the function pointer.

>But C is meant to be used for low-level things.

There is still undefined behavior in C and accessing before the start of an
array (in this case the function pointer) is undefined. Standard C says
function pointers and other pointers don't need to be the same size or
otherwise and not convertable (though it is a requirement for POSIX). 

With  -pedantic-errors we get an error message due to this :):
```
<source>: In function 'is_trampoline':
<source>:5:25: error: ISO C forbids initialization between function pointer and
'void *' [-Wpedantic]
    5 |   void* tramp_address = tramp;
      |                         ^~~~~
```

Reply via email to