[Bug c/15883] New: allow mixed regparm / standard calling convention
avi at exanet dot com
gcc-bugzilla@gcc.gnu.org
Tue Jun 8 20:47:00 GMT 2004
Currently, the only way to safely use regparm is to compile everything (system
libraries, third party libraries, and the application) with it. This is usually
only possible for completely self-contained projects, such as the Linux kernel.
While it is possible to specify that a particular function uses the regparm
calling convention, via __attribute__((regparm)), it is impossible to do so
safely:
- (C, C++) gcc silently converts a regparm function to a non-regparm function
pointer:
__attribute__((regparm(3)))
int f(int x) { return x+1; }
int (*p)(int x) = f; // ERROR
- (C++) g++ allows an overriding virtual function to have a different calling
convention that the overridden function:
struct C {
__attribute__((regparm(3)))
virtual int f(int x) { return x+1; }
};
struct D : C {
virtual int f(int x) { return x+2; } // ERROR
};
The calling convention should be treated similarly to 'const'. Conversion from
one convention to the other should be flagged as an error.
Other features that would improve regparm usability:
- a pragma to set calling convention for an entire header
- allow setting the calling convention for a C++ class, setting the default for
all its members.
--
Summary: allow mixed regparm / standard calling convention
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: avi at exanet dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-redhat-linux
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15883
More information about the Gcc-bugs
mailing list