This is the mail archive of the gcc@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]

Re: Request for a C++ warning for undefined behaviour


Hi,

On 13 Aug 2003, skaller wrote:

> > int x = x + 1;
> >
> Actually there is an interesting variant that exhibits both
> this issue and the one raise by Michael Matx:
>
> struct X { int x; X() : x(x) {} };
>
> which not only initialises a variable to itself,
> but also manages to refer to a variable before its
> ctor-initialiser has initialised it :-)

Although this is not at all the same as my original issue, which was about
calling members of an object under construction whose bases weren't yet
initialized.

But if we are constructing interesting examples I have another one:

struct X { int x; X(int x) : x(x) {} };

This one is ok (!) and initializes X::x with the value of the constructor
parameter 'x' ;-)


Ciao,
Michael.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]