gnu optimization bug

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Abhishek

    gnu optimization bug

    Recently i found that my C++ program was running fine with no
    optimization and giving segmentation fault with error code 139 when
    compiled with optimization level 2. I searched somewhat but never find
    any systematic solution. In my recent attempt, i found the problem with
    the optimization tool itself, which iam discussing here.

    I found that the problem of segmentation fault was boiled down to a
    statement of the form A = B, with no pointer or array usage, so forget
    about the illegal memory write problems. When i removed this statement,
    the problem disappers, so concluded that the segmentation fault problem
    is with this statement. A careful study revealed that this statement
    was redundant because A was never used in the program after this
    statement. So i inserted one more statement after the above statement
    which is "X = A", where X is a dummy variable and in that case the
    problem again disappears. Inserting this new statement has made my
    initial statement no more redundant.

    I think the optimization tool had detected that A = B is a redundant
    statement but failed to do its work. So its a clear bug in the
    optimization tool itself.

    The gcc -v output of my system is following:

    Using built-in specs.
    Target: i486-linux-gnu
    Configured with: ../src/configure -v
    --enable-languages=c,c++ ,java,f95,objc, ada,treelang --prefix=/usr
    --enable-shared --with-system-zlib --libexecdir=/usr/lib
    --without-included-gettext --enable-threads=posix --enable-nls
    --program-suffix=-4.0 --enable-__cxa_atexit
    --enable-libstdcxx-allocator=mt --enable-clocale=gnu
    --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
    --enable-gtk-cairo
    --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
    --enable-mpfr --disable-werror --enable-checking=releas e i486-linux-gnu
    Thread model: posix
    gcc version 4.0.2 (Debian 4.0.2-2)

  • Sharad Kala

    #2
    Re: gnu optimization bug


    "Abhishek" <abhishekh.seth @gmail.com> wrote in message

    | Recently i found that my C++ program was running fine with no
    | optimization and giving segmentation fault with error code 139 when
    | compiled with optimization level 2. I searched somewhat but never find
    | any systematic solution. In my recent attempt, i found the problem with
    | the optimization tool itself, which iam discussing here.

    You should take the topic to the gcc mailing list.

    Sharad


    Comment

    • Kai-Uwe Bux

      #3
      Re: gnu optimization bug

      Abhishek wrote:
      [g++ bug report redacted]

      Bug reports for particular compilers are off-topic in this group. All we can
      do is help you determine whether there is actually a bug. Since you did not
      post the code, which may or may not exhibit undefined behavior, we cannot
      help with that either.


      Best

      Kai-Uwe Bux

      Comment

      • Rolf Magnus

        #4
        Re: gnu optimization bug

        Abhishek wrote:
        [color=blue]
        > Recently i found that my C++ program was running fine with no
        > optimization and giving segmentation fault with error code 139 when
        > compiled with optimization level 2. I searched somewhat but never find
        > any systematic solution. In my recent attempt, i found the problem with
        > the optimization tool itself, which iam discussing here.
        >
        > I found that the problem of segmentation fault was boiled down to a
        > statement of the form A = B, with no pointer or array usage, so forget
        > about the illegal memory write problems. When i removed this statement,
        > the problem disappers, so concluded that the segmentation fault problem
        > is with this statement. A careful study revealed that this statement
        > was redundant because A was never used in the program after this
        > statement. So i inserted one more statement after the above statement
        > which is "X = A", where X is a dummy variable and in that case the
        > problem again disappears. Inserting this new statement has made my
        > initial statement no more redundant.
        >
        > I think the optimization tool had detected that A = B is a redundant
        > statement but failed to do its work. So its a clear bug in the
        > optimization tool itself.[/color]

        Without any more code, it's hard to say if you're right. What type are A and
        B? Could you provide a minimal, but complete program that shows the
        behavior. Sometimes, a program crash happens in a place different from the
        one that contains the error.

        As others already mentioned: A g++ bug report would have to go to a
        different place than here, but here, we could tell you if it's actually a
        bug in the compiler or an error in your code. However, for that, you'd have
        to show some code.

        Comment

        Working...