This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Dear all,
I would like to post two fault reports for the GNU C/C++ compiler 3.3-e500.
We use the compiler to generate code for a PowerPc processor and one bug
is related to to code generator and the other bug is related to the
compiler front
end.
Used invokation line for the 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>
Z.CPP -oZ.O
Fault report 1 (templates and pointer to const member):
=======================================================
// example program 1
template <typename T_>
class C1
{
public:
C1 ();
~C1 ();
const int C1<T_>::* getPtr () const;
private:
int x;
T_ y;
};
template <typename T_>
const int C1<T_>::* C1<T_>::getPtr () const
{ return &C1<T_>::x; } // <-- line 17
The compiler gives the following error message:
z.CPP:17: error: too few template parameter lists in declaration of `const
int
C1<T_>::* C1<T_>::getPtr() const'
We get no error message if a typedef is introduced:
// example program 2
template <typename T_>
class C1
{
typedef const int C1<T_>::* T_C1_INT_PTR;
public:
C1 ();
~C1 ();
T_C1_INT_PTR getPtr () const;
private:
int x;
T_ y;
};
template <typename T_>
typename C1<T_>::T_C1_INT_PTR C1<T_>::getPtr () const
{ return &C1<T_>::x; }
Fault report 2 (::delete and multiple inheritance):
===================================================
// example program
class B1
{
public:
virtual ~B1 () throw();
protected:
B1 ();
private:
int x;
};
class B2
{
public:
virtual ~B2 () throw();
protected:
B2 ();
private:
int x;
};
class D : public B1, public B2
{
public:
D ();
~D () throw();
private:
int y;
};
void f1 (D*);
void f2 (B2*);
void f3 (B1*);
void f (void)
{
f1 (::new D);
f2 (::new D); // correct address adjustement D -> B2, see assembler
listing
f3 (::new D);
}
void f1 (D* p) { ::delete p; }
void f2 (B2* p) { ::delete p; } // missing address adjustment B2 -> D for
the call of ::operator delete()
void f3 (B1* p) { ::delete p; }
In function f2() the deallocation function ::operator delete() (assembler
call 'bl _ZdlPv') is called, but the deallocation function does not get the
address of the
dynamic D-object.
The corresponding assembler listing is attached as file GNU1.TXT.
I think that the code above is legal, cf. the C++ standard 5.3.4/9, 5.3.4
/18
(for constructor exceptions) and 5.3.5/8.
With kind regards
W. Roehrl
(See attached file: Gnu1.txt)Attachment:
Gnu1.txt
Description: Binary data
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |