The following code crashes g++ 4.1.3 :
*START OF FILE**
#include
using namespace std;
double arctan(double x)
{
int i=1,n=20;
double c=1.0,arct=0.0,paf=1.0,eps=0.1,hab;
hab=(x/(1+x*x));
do
{
arct+=paf;
c+=2i/(2i+1);
paf=(c*hab);
i++;
}
while((ieps));
arct*=hab;
return arct;
}
int main()
{
double Pi;
Pi=4*(4*arctan(1/5)-arctan(1/239));
cout< search starts here:
/usr/include/c++/4.1.3
/usr/include/c++/4.1.3/i486-linux-gnu
/usr/include/c++/4.1.3/backward
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.1.3/include
/usr/include
End of search list.
GNU C++ version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
(i486-linux-gnu)
compiled by GNU C version 4.1.3 20070929 (prerelease) (Ubuntu
4.1.2-16ubuntu2).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 3cc47be363985179cfafdceddd0e8f5d
test.cpp: In function double arctan(double):
test.cpp:12: internal compiler error: in const_binop, at fold-const.c:1641
Please submit a full bug report,
with preprocessed source if appropriate.
See http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions,
see .
Preprocessed source stored into /tmp/cczf63dY.out file, please attach this to
your bugreport.
--
Summary: g++ crashes on simple 20-line source file
Product: gcc
Version: 4.1.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nmaquet at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34086