help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Gcc 3.2.2 attribute handling bug


From: John Max Skaller
Subject: Gcc 3.2.2 attribute handling bug
Date: Fri, 11 Feb 2005 11:16:34 +1100
User-agent: Pan/0.13.3 (That cat's something I can't explain)

I wonder if someone might report this to the gcc developers
mailing list if the bug remains in later versions and has
not yet been reported.

The annotation

__attribute_(regparm(2))

can significantly increase the performance of a function
on the x86. 

Unfortunately, g++ 3.2.2 fails to check the use of this
attribute correctly. 

It is possible to declare a function (without the attribute),
call it, and then declare the function again WITH the attribute,
in particular in the definition.

This can lead to a mismatch between the calling protocol
used to generate a call, and the one used to generate
the function.

This attribute (and any others affecting calling protocol)
must be regarded as part of the type of the function,
and a subsequent declaration, particularly a definition,
should either match the previously declared type,
or the declaration should be 'modified' to do so.

For example, like linkage attributes, it would be
OK to 'inherit' regparm attribute, but adding it
to an already declared function must NOT be permitted.

This is a fatal error, and failure to detect it
can (and on my box does) lead to a segfault.

[I was actually going to ask whether this works
properly with virtual function dispatch, however it seems
pointless to ask about this when gcc doesn't even
get the basic case right.]





reply via email to

[Prev in Thread] Current Thread [Next in Thread]