The behaviour of C++ with declspec sequences on pointer declarations has 
changed:

Compiling:
/* declspec.c */
int i = 1;
int   __attribute__((aligned(16))) * foo = &i;
int * __attribute__((aligned(16)))   bar = &i;

as gcc -xc -W -S declspec.c, I get:

<snip>
        .section .drectve

        .ascii " -export:bar,data"
        .ascii " -export:foo,data"


Compiling above as gcc -xc++ -W -S declspec.c, I get:

<snip>
        .section .drectve

        .ascii " -export:foo,data"

The attribute is silently ignored for bar.

In gcc-3.3.3 and 3.4.4 , the dllexport attribute was applied
to both declarations in C++, as in C.

In old gcc-2.95.2, the behaviour was the same as in 4.0.0

A similar difference between C and C++ is observed if I
substitute aligned(16) for dllexport, ie, foo is 16-byte
aligned, bar is 4-btye aligned in C++, while both are 16-
byte aligned in C.

Is this a bug, or are declspec sequence rules being followed
more strictly now in C++?  If the latter, should there be
some kind of warning at least with -Wextra?

Danny

-- 
           Summary: Declspec  sequences on pointer declarations: C++ vs C
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dannysmith at users dot sourceforge dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-mingw32
  GCC host triplet: i686-pc-mingw32
GCC target triplet: i686-pc-mingw32


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

Reply via email to