c++/2711: ice in c_expand_expr (namespace directive)

Peter Schmid schmid@snake.iap.physik.tu-darmstadt.de
Tue May 1 17:36:00 GMT 2001


>Number:         2711
>Category:       c++
>Synopsis:       ice in c_expand_expr (namespace directive)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-illegal-code
>Submitter-Id:   net
>Arrival-Date:   Tue May 01 17:36:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Peter Schmid
>Release:        3.0 20010501 (prerelease)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.3 #35 Sat Mar 31 22:08:25 CEST 2001 i686 unknown
Architecture: i686
SuSE 7.1
Glibc 2.2
GNU assembler 2.11.90.0.4
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
>Description:
Compiling the source code t.C generates an internal compiler error. If
the using namespace std directive is moved in front of the function f()
the crash does not occur. gcc 2.95 compiles the code without a problem.

>How-To-Repeat:
Source code t.C

namespace std
{
    template<typename _Tp>
    class complex
    {
    public:
        complex(const _Tp& = _Tp(), const _Tp & = _Tp());
        _Tp real() const;
        _Tp imag() const;

    private:
        _Tp _M_real, _M_imag;
    };

    template<typename _Tp>
    inline 
    complex<_Tp>::complex(const _Tp& __r, const _Tp& __i)
            : _M_real(__r), _M_imag(__i) { }

    template<typename _Tp>
    inline _Tp
    complex<_Tp>::real() const { return _M_real; }

    template<typename _Tp>
    inline _Tp
    complex<_Tp>::imag() const { return _M_imag; }
    
    template<typename _Tp>
    inline complex<_Tp>
    conj(const complex<_Tp>& __z)
    { return complex<_Tp>(__z.real(), -__z.imag()); }

    template<> class complex<double>
    {
    public:
        complex(double = 0.0, double = 0.0);
        double real() const;
        double imag() const;
    private:
        typedef __complex__ double _ComplexT;
        _ComplexT _M_value;
    };

    inline
    complex<double>::complex(double r, double i)
    {
        __real__ _M_value = r;
        __imag__ _M_value = i;
    }

    inline double
    complex<double>::real() const
    { return __real__ _M_value; }
    
    inline double
    complex<double>::imag() const
    { return __imag__ _M_value; }

}

void f()
{
    using namespace std;   
    complex<double> c(1.0, 2.0);
    complex<double> e = conj(c);
}


int main()
{
    f();
}

Compiling t.C
g++ -v -o t t.C -W -Wall 
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
Thread model: posix
gcc version 3.0 20010501 (prerelease)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -W -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ t.C -D__GNUG__=3 -D_GNU_SOURCE -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase t.C -W -Wall -version -o /tmp/ccGO400h.s
GNU CPP version 3.0 20010501 (prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0 20010501 (prerelease) (i686-pc-linux-gnu)
	compiled by GNU C version 3.0 20010501 (prerelease).
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/include/g++-v3/i686-pc-linux-gnu
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.0/include
 /usr/local/i686-pc-linux-gnu/include
 /usr/include
End of search list.
t.C: In function `void f()':
t.C:65: warning: unused variable `std::complex<double> e'
t.C:65: Internal compiler error in c_expand_expr, at c-common.c:4116
Please submit a full bug report, with preprocessed source if appropriate.
See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list