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

--- Comment #8 from Adam Warner <adam at consulting dot net.nz> ---
Joseph, you're correct:

  4005fa:       b8 c6 05 40 00          mov    eax,0x4005c6
  4005ff:       89 05 cf 04 20 00       mov    DWORD PTR [rip+0x2004cf],eax    
   # 600ad4 <computable_at_load_time_a>
  400605:       b8 c6 05 40 00          mov    eax,0x4005c6
  40060a:       89 05 c8 04 20 00       mov    DWORD PTR [rip+0x2004c8],eax    
   # 600ad8 <computable_at_load_time_b>

0x4005c6 is the address of the function which is loaded into the lookup table
by a static initializer function at run time.

This is identical to the workaround in C where a lookup table of 32-bit
pointers has to be populated at run time. I agree it is not significant that
the code is accepted for C++. I'm sorry about that.

What I've done in the past is use Perl to generate printf statements to output
the 32-bit addresses as an integer array. The generated array is then compiled
into the binary. A command-line option performs a check that the integer
addresses match the newly compiled function addresses. It usually takes one
additional generation/compilation before they all match up.

It is ridiculous this x86_64 workaround is required to map constants into
memory at load time when the functions occupy (under the default code model)
the same lower 31-bit address space as i386.

The original issue from six years ago is that compilation fails with the error
"initializer element is not computable at load time". These calculations are
computable at load time so the error message is spurious. But from a C language
perspective they might not be computable at load time. Thus I believe a
compiler warning is more appropriate than an error. That's the path to
finalising this bug report:

1. Can you confirm from a technical perspective that the error is spurious? If
so the bug report is CONFIRMED. If there are in fact good technical reasons why
the error is valid then please close the bug report as INVALID.

2. If the bug report is confirmed then please decide whether the project will
turn the error message into a warning. If the project will not do this then
please close the bug report as WONTFIX. This part is ultimately a political
decision. Either way it would be nice to have a resolution.

Reply via email to