This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/55339] Generated code hangs with -O2 on Linux ppc
- From: "anton.katilin at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 15 Nov 2012 11:28:32 +0000
- Subject: [Bug c++/55339] Generated code hangs with -O2 on Linux ppc
- Auto-submitted: auto-generated
- References: <bug-55339-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55339
--- Comment #1 from anton.katilin at gmail dot com 2012-11-15 11:28:32 UTC ---
Compile with:
-------------------------------------
export PATH=/opt/gcc-4.7.2/bin:$PATH
g++ -m32 -fPIC -O2 *.cpp -o test-O2.bin
g++ -m32 -fPIC -O1 *.cpp -o test-O1.bin
Please find the source code of the test below.
-------------------------------------
Test.cpp
-------------------------------------
#include <stdio.h>
#include "Foo.h"
int main() {
try {
printf("entering...\n");
fflush(stdout);
YS(-1); // will throw exception
printf("must never reach\n");
}
catch (int) {
printf("exception caught, as expected\n");
}
printf("OK\n");
return 0;
}
-------------------------------------
Foo.h
-------------------------------------
#pragma once
void foo();
void checkPositive(int);
class YS {
public:
YS(int capacity) {
checkPositive(capacity);
}
~YS() {
foo();
}
};
void throwException(const YS&);
-------------------------------------
Foo.cpp
-------------------------------------
#include "Foo.h"
void foo() {
}
void checkPositive(int v) {
if (v <= 0) {
throwException(10);
}
}
void throwException(const YS&) {
throw int(1);
}