isnan() causes segfault

Eric Lilja mindcooler@gmail.com
Thu Nov 30 14:50:00 GMT 2006


Hello, I'm working as a laborations assistant in a C++ course. The 
students are using Sun workstations and gcc (well, g++) version 3.4.6 to 
do the labs. I don't particularly like these workstations so I have 
cygwin installed on my laptop and I use it compile and test the 
student's programs.
Anyway, I recently rejected code from two students because it 
stackdumped on my machine. They insisted that it works as expected on 
their workstation. I thought, at first, that they had simply stepped 
into the realm of undefined behaviour and it just happened to work on 
the Sun workstations.
But I when I started investigating exactly what was causing the 
stackdump I found that it was a call to isnan (this was a fairly large 
program). I tried to reproduce it using a very simple test program, but 
I couldn't at first until I changed the compiler flags.

The following program stackdumps:
#include <cmath>

int
main()
{
    std::isnan(3);
}
If compiled with:
$ g++ -Wall -Wextra -std=c++98 -pedantic -g isnantest.cpp -o run
(those are the flags we have been using in this course).
But it doesn't stackdump if compiled simply with:
$ make isnantest
g++     isnantest.cpp   -o isnantest

Comments? cygcheck.out attached.

/ E
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20061130/57a41feb/attachment.ksh>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list