This is the mail archive of the cygwin-apps mailing list for the Cygwin 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]

64bit: Possible optimizer bug in g++ 4.8.0 20130319


Thanks for providing 64-bit Cygwin.

A 64bit test build of smartmontools 6.1 segfaults after throw (It uses throw frequently because I replaced 'exit(status)' with 'throw (int)(status)' during C -> C++ migration). Changing the optimization level from -O2 to -O1 or -Os fixes the segfault.

I tracked this down to the attached easy testcase:

$ uname -srvmo
CYGWIN_NT-6.1 1.7.18(0.263/5/3) 2013-03-22 15:00 x86_64 Cygwin

$ g++ --version
g++ (GCC) 4.8.0 20130319 (prerelease)

$ g++ -o throw -O1 throw.cc

$ ./throw

$ echo $?
42

$ g++ -o throw -O2 throw.cc

$ ./throw
Segmentation fault

$ echo $?
139

Changing the size of the std::string array to <= 31 also fixes the segfault.

Hope this helps.

Christian

#include <string>

static int main_worker(int argc)
{
  std::string s[32]; // [31] => no segfault
  if (argc < 2)
    throw 42;
  return argc;
}

int main(int argc, char **argv)
{
  try {
    return main_worker(argc);
  }
  catch (int i) {
    return i;
  }
}

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