c/8859: [CygWin] Initializer element allegedly not constant

Danny Smith dannysmith@clear.net.nz
Mon Apr 7 21:47:00 GMT 2003


http://gcc.gnu.org/cgi-bin/gnatseb.pl?cmd=view%20audit-trail&database=gc
c&pr=8859


This is not a a regression, but  YA  "dllimport" expectation that the MS
native compiler fulfills, but GCC does not.

The dllimport attribute,  does this in config/i386/winnt.c
(i386_pe_mark_dllimport):

at line 343, config/i386/winnt.c:

  /* Can't treat a pointer to this as a constant address */
  DECL_NON_ADDR_CONST_P (decl) = 1;

This is because:

__attribute__((dllimport)) int foo;

really means something like:

extern int* _imp__foo;
#define foo  *_imp__foo

Because of this, the assignment error in the PR is actually valid: in C
it is illegal
to assign to non-constant at global scope. in C++  it works but requires
dynamic
global initialisation.

Apparently, the native MS compiler ignores the the dllimport attribute
in (some/all??) cases of assignment at global scope.

Golly, I wonder if these MS rules are documented somewhere.
I haven't found all the rules yet.


Danny



More information about the Gcc-bugs mailing list