Fault report

Wolfgang.Roehrl@de.gi-de.com Wolfgang.Roehrl@de.gi-de.com
Thu Apr 15 12:04:00 GMT 2004





Dear all,

I would like to post a fault report for the GNU C/C++ compiler 3.3-e500.

We use the compiler to generate code for a PowerPC processor.

Used invokation line for the GNU C++ compiler:

ccppc -c -x c++ -ansi -Wall -Werror -mcpu=8540 -fverbose-asm -mbig
-mmultiple
      -mno-string -mstrict-align -O3 -fno-exceptions -fno-rtti
      -I<different include paths>
      -D<differen #define's>
      Y.CPP -oY.O



// example program

#define MODE 1         // 0 or 1


template <typename T_>
struct type_tag
{
    typedef T_ type;
};



template <typename T_>
struct XYZ
{
    XYZ ()
    {
        ptr1 = new T_;
        ptr2 = 0;
    }

    template <typename U_>
    XYZ (const type_tag<U_>&)
    {
        ptr1 = 0;
        ptr2 = new U_;
    }

    template <typename U_, typename P_>
    XYZ (const type_tag<U_>&, const P_& p)
    {
        ptr1 = 0;
        ptr2 = new U_(p);
    }

private:
    T_* ptr1;
    void* ptr2;
};


XYZ<int> xyz1;

type_tag<char> t;
XYZ<int> xyz2 (t);
XYZ<int> xyz3 (t, 'a');

typedef type_tag<char> TT;

XYZ<int> xyz4 (TT());                       // <--- object is not allocated
XYZ<int> xyz5 (type_tag<char>());           // <--- object is not allocated

#if (MODE == 1)
  XYZ<int> xyz6 (TT(), 'a');                // <--- 'syntax error' (line
53)
  XYZ<int> xyz7 (type_tag<char>(), 'a');    // <--- 'syntax error' (line
54)
#endif


If the macro MODE is defined to 1, the compiler gives the following error
messages:

y.CPP:53: error: type specifier omitted for parameter
y.CPP:53: error: syntax error before 'a'
y.CPP:54: error: type specifier omitted for parameter
y.CPP:54: error: syntax error before 'a'


If MODE is defined to 0, I get no error message but the objects xyz4 and
xyz5
are neither allocated nor constructed. (The corresponding assembler listing
is
attached as file GNU2.TXT.)



With kind regards
W. Roehrl

(See attached file: Gnu2.txt)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Gnu2.txt
Type: application/octet-stream
Size: 3274 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20040415/874e26b7/attachment.obj>


More information about the Gcc-bugs mailing list