[LLVMbugs] [Bug 11939] New: Regression: Crash on codegen for reference to temporary(?)
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Feb 7 03:33:44 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=11939
Bug #: 11939
Summary: Regression: Crash on codegen for reference to
temporary(?)
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++0x
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jonathan.sauer at gmx.de
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 8013
--> http://llvm.org/bugs/attachment.cgi?id=8013
Complete log of clang run
The following program crashes clang r149863 during codegen:
static void foo(const unsigned int&)
{
}
// Adapted from libc++'s chrono header
template <typename Rep, typename Period>
class duration {
public:
duration(const Rep&);
Rep count() const;
};
typedef duration<long long, short> milliseconds;
typedef duration<long long, int> nanoseconds;
template <class ToDuration, class Rep, class Period>
ToDuration duration_cast(const duration<Rep, Period>& d);
int main(int, char**)
{
long long const millisPassed =
duration_cast<milliseconds>(nanoseconds(1)).count(); // Crashes
//unsigned int const millisPassed =
duration_cast<milliseconds>(nanoseconds(1)).count(); // OK
//long long const millisPassed = 462379463473946239LL; // OK
foo(millisPassed);
}
This results in (full log attached):
$ clang++ -std=c++0x -v clang.cpp
Assertion failed: ((ND->isUsed(false) || !isa<VarDecl>(ND) ||
!E->getLocation().isValid()) && "Should not use decl without marking it
used!"), function EmitDeclRefLValue, file
/Users/rynnsauer/LLVM/llvm/tools/clang/lib/CodeGen/CGExpr.cpp, line 1377.
[...]
1. <eof> parser at end of file
2. clang.cpp:22:5: LLVM IR generation of declaration 'main'
3. clang.cpp:22:5: Generating code for declaration 'main'
4. clang.cpp:23:1: LLVM IR generation of compound statement ('{}')
It seems that this happens while creating a const reference to the temporary
unsigned int into which <millisPassed> is converted. Changing <millisPassed>'s
type to unsigned int resolves the crash (perhaps because a temporary is no
longer necessary). So does directly assigning a value to <millisPassed>.
Clang r149240 does not crash when compiling the program.
--
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