[cfe-dev] Strange dimension errors in a custom matrix class
Tony Kelman
kelman at berkeley.edu
Sun Feb 9 00:33:03 PST 2014
> I'm seeing some strange runtime errors that don't occur when the same code
> is built with g++. I've tried to cut down the class in question and reduce
> the error to a small test case, and posted the result at
> https://gist.github.com/8875125
Following up here. I've found and figured out how to use the absolutely
amazing tool C-Reduce (http://embed.cs.utah.edu/creduce/) which I imagine
this list is familiar with. The result is the following:
class A
{
public:
A (const A &);
~A ();
};
A::A (const A &)
{
}
A & fn1 ()
{
}
A::~A ()
{
}
A a = fn1 ();
int
main ()
{
}
$ g++ -g -o dmtest-g++ dmtest.cxx && ./dmtest-g++
succeeds silently, while
$ clang++ -g -o dmtest-clang dmtest.cxx && ./dmtest-clang
gives a warning "control reaches end of non-void function" during
compilation, and a runtime error "Illegal instruction (core dumped)". This
comparison was on Ubuntu 13.10 as it was the easiest platform for me to get
C-Reduce running on.
Is this difference in behavior between the two compilers expected and/or
intended, or is this a bug in Clang? If the former, does anyone have any
suggestions for how to translate this back into a workaround for the
purposes of the real code that originally ran into this difference?
Thanks,
Tony
More information about the cfe-dev
mailing list