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] New: [3.3 REGRESSION] Assertion does not seem to work correctly anymore


The following code fails the assertion, but I don't understand why. I does work
with 2.95.3. I think it fails in the builtin_expect function.

cat > test.cpp <<EOF
#include <assert.h>

struct Y {
  Y () : _y(0) {}
  int _y;
  int y () const  { return _y; }

};

struct X {
  X () {}

  Y _y;

  inline int x() const { return 0; }
  inline Y y() const { return _y; }

};


int main()
{
  X x;
  assert (x.y().y()==0);

  assert ( ((x.x()==0) && (x.y().y()==0)) );
  return 0;
}
EOF

g++ -DDEBUG -o test test.cpp && ./test

If I replace Y::y() with "return 0;" then it works.

Maybe I'm doing something wrong?? I just installed the new SuSe 9.0 and it also
fails with their compiler.

Here's also the preprocessed source in case my system is not setup right.

# 1 "test.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.cpp"
# 1 "/usr/include/assert.h" 1 3 4
# 36 "/usr/include/assert.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 295 "/usr/include/features.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 296 "/usr/include/features.h" 2 3 4
# 318 "/usr/include/features.h" 3 4
# 1 "/usr/include/gnu/stubs.h" 1 3 4
# 319 "/usr/include/features.h" 2 3 4
# 37 "/usr/include/assert.h" 2 3 4
# 65 "/usr/include/assert.h" 3 4
extern "C" {


extern void __assert_fail (__const char *__assertion, __const char *__file,
                           unsigned int __line, __const char *__function)
     throw () __attribute__ ((__noreturn__));


extern void __assert_perror_fail (int __errnum, __const char *__file,
                                  unsigned int __line,
                                  __const char *__function)
     throw () __attribute__ ((__noreturn__));




extern void __assert (const char *__assertion, const char *__file, int __line)
     throw () __attribute__ ((__noreturn__));


}
# 2 "test.cpp" 2

struct Y {
  Y () : _y(0) {}
  int _y;
  int y () const { return _y; }

};

struct X {
  X () {}

  Y _y;

  inline int x() const { return 0; }
  inline Y y() const { return _y; }

};


int main()
{
  X x;
  (static_cast<void> (__builtin_expect (!!(x.y().y()==0), 1) ? 0 :
(__assert_fail ("x.y().y()==0", "test.cpp", 24, __PRETTY_FUNCTION__), 0)));

  (static_cast<void> (__builtin_expect (!!(((x.x()==0) && (x.y().y()==0))), 1) ?
0 : (__assert_fail ("((x.x()==0) && (x.y().y()==0))", "test.cpp", 26,
__PRETTY_FUNCTION__), 0)));
  return 0;
}

-- 
           Summary: [3.3 REGRESSION] Assertion does not seem to work
                    correctly anymore
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P1
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rmerkert at alphatech dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: gcc (GCC) 3.3.3 20031124 (prerelease)
  GCC host triplet: inux janus 2.4.21-144-smp4G #1 SMP


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]