This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13239] [3.4 regression] Assertion does not seem to work correctly anymore


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]