------- Comment #3 from adam at consulting dot net dot nz  2010-08-17 06:28 
-------
AMD64 non-large code model. Functions occupy lower 2GB of the address space.
Cannot compile an array of 32-bit function addresses:

#include <stddef.h>
#include <stdint.h>
#include <stdio.h>

void fn() {
  printf("Hello, World\n");
}

uint32_t computable_at_load_time_a[]={fn};
uint32_t computable_at_load_time_b[]={(uint32_t) (ptrdiff_t) fn};

int main() {
  return 0;
}

$ gcc -m32 computable_at_load_time.c
computable_at_load_time.c:9: warning: initialization makes integer from pointer
without a cast

$ gcc computable_at_load_time.c
computable_at_load_time.c:9: warning: initialization makes integer from pointer
without a cast
computable_at_load_time.c:9: error: initializer element is not computable at
load time
computable_at_load_time.c:9: error: (near initialization for
‘computable_at_load_time_a[0]’)
computable_at_load_time.c:10: error: initializer element is not constant
computable_at_load_time.c:10: error: (near initialization for
‘computable_at_load_time_b[0]’)

The very good reason for wanting to compile a table of 32-bit function pointers
is to halve the data cache footprint of threaded code.


-- 

adam at consulting dot net dot nz changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |adam at consulting dot net
                   |                            |dot nz


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

Reply via email to