This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/48933] New: Infinite recursion in tr1/cmath functions with complex parameters
- From: "bisqwit at iki dot fi" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 9 May 2011 10:14:23 +0000
- Subject: [Bug libstdc++/48933] New: Infinite recursion in tr1/cmath functions with complex parameters
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48933
Summary: Infinite recursion in tr1/cmath functions with complex
parameters
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: bisqwit@iki.fi
CC: warp@iki.fi
All of the function calls in this example code produce a stack overflow due to
infinite recursion, regardless of optimization level.
Compile with: g++ code.cc
Tested on the following gcc versions: 4.2.4 4.3.5 4.4.6 4.5.2 4.6.1
No compiler warnings or errors are emitted. (Tried even -Wall -W -pedantic
-ansi).
Does not happen on gcc 4.0.4, because tr1/cmath is unavailable.
#include <tr1/cmath>
#include <complex>
int main()
{
std::tr1::tgamma( std::complex<double> (0.5, 0.0) );
std::tr1::cbrt( std::complex<double> (0.5, 0.0) );
std::tr1::asinh( std::complex<double> (0.5, 0.0) );
std::tr1::acosh( std::complex<double> (1.5, 0.0) );
std::tr1::atanh( std::complex<double> (0.5, 0.0) );
std::tr1::erf( std::complex<double> (0.5, 0.0) );
std::tr1::hypot( std::complex<double> (1.0, 0.0) ,
std::complex<double> (1.0, 0.0) );
std::tr1::logb( std::complex<double> (0.5, 0.0) );
std::tr1::round( std::complex<double> (0.5, 0.0) );
std::tr1::trunc( std::complex<double> (0.5, 0.0) );
}
The bug can be traced to all functions in tr1/cmath that look like this:
template<typename _Tp>
inline typename __gnu_cxx::__promote<_Tp>::__type
cbrt(_Tp __x)
{
typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
return cbrt(__type(__x)); // <-- infinite recursion here
}