This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13239] [3.4 regression] Assertion does not seem to work correctly anymore
- From: "rmerkert at alphatech dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 2 Dec 2003 23:40:56 -0000
- Subject: [Bug c++/13239] [3.4 regression] Assertion does not seem to work correctly anymore
- References: <20031130163447.13239.rmerkert@alphatech.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From rmerkert at alphatech dot com 2003-12-02 23:40 -------
I think it's the __builtin_expect that does not work. This example is reduced to
use of __builtin_expect only and it should be possible to replicate it on any
system that uses builtin_expect.
The key to this problem is the use the expression
"__builtin_expect (... ,1) ? 0 : -1" (replace -1 with any number other than 1)
and the example fails. Use 1 and it works!
Looks like an optimization problem.
#include <cstdio>
struct Y {
Y () : _y(0) {}
//Y (const Y& y) : _y(y._y) {}
int _y;
};
extern Y bar();
extern bool foo();
int main()
{
int x = __builtin_expect(foo() && (bar()._y)==0,1) ? 0 : -1;
::std::printf("%d\n",x);
return x;
}
bool foo() { return true; }
Y bar() { return Y(); }
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13239