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++/12789] New: [tree-ssa] Miscompilation of small program


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12789

           Summary: [tree-ssa] Miscompilation of small program
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at dealii dot org
                CC: gcc-bugs at gcc dot gnu dot org

This small program
---------------------------
#include <fstream>
#include <string>

void foo (const int i) {
  std::ifstream in("irrelevant");
  std::string line;
  if (i == 1) return;
  foo (1);
}

int main () {
  foo (0);
}
---------------------------
segfaults on running when compiled with the tree-ssa
branch from
  gcc version 3.5-tree-ssa 20031024 (merged 20031017)
It doesn't segfault with mainline from the same day, though.
Assuming that the code in libstdc++ is the same on the two
branches, this means that something is being miscompiled. This
could, theoretically also include a miscompilation in libstdc++
itself, since I can't get around using parts of it, but it 
strikes me as odd that I need the tail recursion in foo() to
actually trigger the bug in the program. Maybe it is just
some interaction of the tail recursion and the stack space/
constructors/exception handling details of the objects in use
in this function that make this happen, so this could actually
be simple to track down than it looks like.

W.


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