[LLVMbugs] [Bug 12498] New: clang erroneously compiles conversion of initializer_list to forward-declared class
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Apr 8 10:52:45 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12498
Bug #: 12498
Summary: clang erroneously compiles conversion of
initializer_list to forward-declared class
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++11
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jonathan.sauer at gmx.de
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
The following program compiles with clang r154288, even though it shouldn't:
class ArrayRef;
struct C {
void foo(const ArrayRef&); // (Mis-)compiles
//void foo(ArrayRef); // Error
};
static void bar(C* c)
{
c->foo({ nullptr, 1 });
}
int main(int, char**)
{
bar(nullptr);
}
This should result in a compile error, as ArrayRef is merely forward-declared
and thus has no constructor that could be called in bar. Instead, clang simply
drops the call to "foo" (taken from Shark's static analyzer, no optimizations):
bar(C*):
pushq %rbp
movq %rsp, %rbp
movq %rdi, -8(%rbp)
popq %rbp
ret
When foo expects the ArrayRef by value instead of by const reference, clang
correctly raises a compile error.
--
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