Skip to content

C backend mishandles C++ struct return #2497

@sunfishcode

Description

@sunfishcode
Bugzilla Link 2125
Resolution DUPLICATE
Resolved on Feb 07, 2009 16:26
Version trunk
OS All
CC @edwintorok

Extended Description

Compiling the following C++ testcase:

#include
#include
using namespace std;

int main()
{
ostringstream oss(string(1162*9, 'x'));
oss.str();
return 0;
}

with llvm-g++ -emit-llvm and using llc -march=c to produce a C
source file, compiling that and executing it, gets a Segmentation
Fault, at least on x86 Darwin. The problem is the call to str(), which returns
a std::string by value. The generated C source has str() returning a
small struct by value, however the library is expecting it to be returned
by hidden-argument because std::string has a copy constructor.

This is causing bigfib and possibly other llvm-test tests to fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilladuplicateResolved as duplicate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions