[LLVMbugs] [Bug 12208] New: clang++ with -fno-elide-constructors generates incorrect code
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Mar 8 10:58:06 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=12208
Bug #: 12208
Summary: clang++ with -fno-elide-constructors generates
incorrect code
Product: clang
Version: unspecified
Platform: PC
OS/Version: FreeBSD
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: adamartin at freebsd.org
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 8156
--> http://llvm.org/bugs/attachment.cgi?id=8156
Sample program mentioned in post.
Compiling and then running the following simple program:
// Begin sample program
#include <string>
int
main()
{
const std::string tmp( "Left" + std::string( "Middle" ) + "Right" );
}
// End sample program
Will generate segmentation faults on FreeBSD/amd64 systems, when using
-fno-elide-constructors
Similar string concatenation constructions also seem to fail. A simple look at
the backtrace (when also compiled with -O0 -g -fno-inline) in gdb gives me
this:
Program received signal SIGSEGV, Segmentation fault.
0x00000008007ca718 in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::basic_string ()
from /usr/lib/libstdc++.so.6
(gdb) bt
#0 0x00000008007ca718 in std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::basic_string ()
from /usr/lib/libstdc++.so.6
#1 0x0000000000400cc8 in std::operator+<char, std::char_traits<char>,
std::allocator<char> > (__lhs=@0x7fffffffe098,
__rhs=0x400e88 "Right") at basic_string.h:2110
#2 0x0000000000400bb8 in main () at test.cc:6
(gdb) up
#1 0x0000000000400cc8 in std::operator+<char, std::char_traits<char>,
std::allocator<char> > (__lhs=@0x7fffffffe098,
__rhs=0x400e88 "Right") at basic_string.h:2110
2110 {
(gdb) p __lhs
$1 = (std::basic_string<char> &) @0x7fffffffe098: {
_M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> =
{<No data fields>}, <No data fields>},
_M_p = 0x1 <Error reading address 0x1: Bad address>}, static npos =
<optimized out>}
(gdb)
It seems that the "__lhs" parameter to std::operator+( ... ) is being mangled
somehow, as it has an incorrect internal state.
Please note that the -fno-elide-constructors option is required to reproduce
this behavior. If compiled without that option, the sample code behaves as
expected. Other options are not required to reproduce this behavior.
--
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