From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12483 invoked by alias); 7 Apr 2003 21:56:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 12469 invoked by uid 71); 7 Apr 2003 21:56:00 -0000 Date: Mon, 07 Apr 2003 21:56:00 -0000 Message-ID: <20030407215600.12468.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Danny Smith Subject: Re: c/8859: [CygWin] Initializer element allegedly not constant Reply-To: Danny Smith X-SW-Source: 2003-04/txt/msg00318.txt.bz2 List-Id: The following reply was made to PR c/8859; it has been noted by GNATS. From: Danny Smith To: mlt@bredband.net, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org Cc: Subject: Re: c/8859: [CygWin] Initializer element allegedly not constant Date: Mon, 07 Apr 2003 22:49:35 +0100 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