Bug 20221 - Declspec sequences on pointer declarations: C++ vs C
Summary: Declspec sequences on pointer declarations: C++ vs C
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.2.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-26 09:20 UTC by Danny Smith
Modified: 2007-09-20 21:53 UTC (History)
1 user (show)

See Also:
Host: i686-pc-mingw32
Target: i686-pc-mingw32
Build: i686-pc-mingw32
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Danny Smith 2005-02-26 09:20:45 UTC
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
Comment 1 Danny Smith 2007-09-20 21:53:23 UTC
With 4.2 and trunk, I get the same (expected) result on C and C++.
Danny