Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 44586 - gcc 3.x - gcc 3.3.2 contains a bug that makes C++ programs assert erroneously
Summary: gcc 3.x - gcc 3.3.2 contains a bug that makes C++ programs assert erroneously
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: High normal
Assignee: Gentoo Toolchain Maintainers
URL: http://gcc.gnu.org/bugzilla/show_bug....
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-13 11:44 UTC by Tamer Fahmy
Modified: 2004-08-26 16:31 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tamer Fahmy 2004-03-13 11:44:41 UTC
there is as bug in gcc version 3.0 til 3.3.2 that has been addressed in gcc
3.3.3 that makes C++ programs using assert.h assert errouneously.

This can be resolved by fixing the assert.h to not use the builtin_expect
optimization or upgrading the compiler to 3.3.3.

Look at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13239 for a deeper
discussion of the problem and example that shows how it breaks.

I just wanted to make you aware of it in case you want to build your
distribution on the gcc 3.3.2 compiler so that you are aware of this issue in advance.

A library where this causes problems and which is contained in your ebuild is
e.g. media-libs/coin.

cheers,
  Tamer.

Reproducible: Always
Steps to Reproduce:
compile the following with 'g++ -o moo moo.cpp':

#include <assert.h>

struct Y {
  Y () : _y(0) {}
  //Y (const Y& y) : _y(y._y) {}
  int _y;
};

bool foo() { return true; }
Y bar() { return Y(); }

int main()
{
  assert (bar()._y==0);
  assert ( foo() && (bar()._y)==0 );
  return 0;
}


Actual Results:  
moo: moo.cpp:15: int main(): Assertion `foo() && (bar()._y)==0' failed.
Aborted
$ echo $?
134


Expected Results:  
if you remove the builtin_expect occurences from assert.h it should behave like
so:
$ ./moo
$ echo $?
0
Comment 1 Tamer Fahmy 2004-06-28 07:50:24 UTC
i guess we can set this one to resolved now since the default gcc on gentoo is now 3.3.3.
Comment 2 solar (RETIRED) gentoo-dev 2004-08-26 16:31:51 UTC
Closing bug per bug reporters request.