[Bug c++/12344] New: stdcall attribute ignored if function returns a pointer (bug+fix)
zap at cobra dot ru
gcc-bugzilla@gcc.gnu.org
Fri Sep 19 21:30:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12344
Summary: stdcall attribute ignored if function returns a pointer
(bug+fix)
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: zap at cobra dot ru
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i386-redhat-linux
Actually the bug is actual for all platforms and all attributes (not just linux and
stdcall). Also it is not 3.3-specific, I've tested many versions up to 3.3 and all have
the same bug present. I've encountered it while woring on the OS/2 port of gcc
which has its own specific attributes.
Here's a sample (test.cpp):
void __attribute__((stdcall)) test1 (int) {}
void *__attribute__((stdcall)) test2 (int) {}
Compiled .s file (gcc -S -s -fno-exceptions -fomit-frame-pointer -O test.cpp,
optimization options used only for cleaner assembler code):
[... skipped ...]
_Z5test1i:
ret $4
[... skipped ...]
_Z5test2i:
ret
The same file compiled as a plain C file works fine.
I've tracked the bug down to gcc/cp/decl.c. Here is the patch that fixes the bug:
--- decl.c 16 Apr 2003 10:10:35 -0000 1.1
+++ decl.c 9 Sep 2003 18:37:40 -0000 1.3
@@ -13613,7 +13613,7 @@
}
else
{
- decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, NULL);
+ decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs);
/* If the declarator is not suitable for a function definition,
cause a syntax error. */
if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL)
More information about the Gcc-bugs
mailing list