[LLVMbugs] [Bug 14989] New: std::stringstream::str() throws exception on Windows
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jan 17 14:23:37 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=14989
Bug #: 14989
Summary: std::stringstream::str() throws exception on Windows
Product: new-bugs
Version: 3.2
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: oget.fedora at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Hi, I downloaded 3.2 source tarballs, and made the following changes before
compiling on Windows XP via MinGW-4.7:
a- In llvm-3.2.src/tools/clang/lib/AST/ItaniumCXXABI.cpp I added the line
AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.7.2);
so that clang++ can find my C++ headers.
b- In llvm-3.2.src/tools/clang/lib/AST/ItaniumCXXABI.cpp, as explained in [1],
I had to change the function getDefaultMethodCallConv(bool isVariadic)
from
CallingConv getDefaultMethodCallConv(bool isVariadic) const {
return CC_C;
}
to
CallingConv getDefaultMethodCallConv(bool isVariadic) const {
if (!isVariadic && Context.getTargetInfo().getTriple().getArch() ==
llvm::Triple::x86)
return CC_X86ThisCall;
else
return CC_C;
}
Otherwise, my executables (created by clang++) crash as soon as I use a
standard library function (Is this bug reported before?).
---
Then I compile llvm with the following options (*):
../llvm-3.2.src/configure --disable-docs --enable-targets=x86
--prefix=/c/mingw --with-extra-ld-options=-static
The last option is to reduce the compilation times (source files that I compile
using clang). Otherwise, every time I call clang, the linker spends ~10 seconds
to resolve the DLLs on Windows, increasing the compilation time a lot. See [2].
Even clang --help takes 10 seconds to print something.
---
After building llvm/clang, I compile the following code:
#include <sstream>
int main()
{
std::stringstream ss;
ss << "hello";
ss.str();
}
via
clang++ -g -O0 ctest.cpp -o ctest.exe
---
When I execute ctest.exe I get the following output:
terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_S_create
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
---
I also tried building llvm-3.2 via --disable-assertions and/or
--enable-optimized but these didn't change the (mis)behavior.
P.S : llvm-3.2 compiled via gcc-4.5 does not have this problem. However with
gcc-4.5, I cannot use the --with-extra-ld-options=-static flag (as the build
fails otherwise, because linker tries to link to a pthread library which is not
available), so I end up having the same problem (*) above and my compilation
times with clang become huge.
Thanks!
[1] http://tehsausage.com/clang-mingw-gcc-4-7
[2]
http://clang-developers.42468.n3.nabble.com/clang-3-1-trunk-r154095-mingw-gcc-4-6-2-slowness-td3887821.html
--
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