[LLVMbugs] [Bug 14531] New: Clang asserts when calling-convention attributes are used on function pointers in C++ C-tors
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Dec 6 14:48:05 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=14531
Bug #: 14531
Summary: Clang asserts when calling-convention attributes are
used on function pointers in C++ C-tors
Product: clang
Version: 3.1
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: Frontend
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: benjamin.j.panning at intel.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Consider the following code:
// *** BEGIN CODE
typedef __attribute__((stdcall)) void StdcallFnTy();
typedef __attribute__((fastcall)) void FastcallFnTy();
class Foo
{
Foo(StdcallFnTy* f) { }
Foo(FastcallFnTy* f) { }
};
// *** END CODE
This produces the following assertion when Clang attempts to merge c-tor
aliases:
Assertion failed: Entry->isDeclaration() && "definition already exists for
alias", file \llvm\tools\clang\lib\CodeGen\CGCXX.cpp, line 161
clang: error: clang frontend command failed with exit code 3 (use -v to see
invocation)
Interestingly, if the calling-convention attributes are replaced by other
non-calling convention attributes, Clang reports an error:
"constructor cannot be redeclared"
It appears that the front end parses the calling-convention attribute and
differentiates between the types StdcallFnTy and FastcallFnTy, but does not
correctly differentiate between the types when creating c-tor aliases. I'm
assuming this is because Clang is grabbing the global value by mangled name and
the mangled names are the same for both c-tors.
I'm not sure what the C/C++ spec calls for on this, but I think it would make
sense to do one of the following:
1. Report the same "constructor cannot be redeclared" error for c-tors whose
type differ only by calling convention.
2. Handle the calling convention when creating c-tor aliases so that the
above code works.
Either one of these would make me happy. Asserts make me sad. :(
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list