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

[patch] fix c++/18016 - warn about self-initialization in constructor init-list


I didn't get this reviewed previously so I'll try again for 4.7 ...


---------- Forwarded message ----------


Here's my attempt to fix PR c++/18016 so that we get a warning from

struct S {
?int i;
?S() : i(i) { }
};

As I said in the audit trail, -Winit-self is broken for C++ (PR
c++/34772) so I made this warn with
-Wuninitialized and not affected by -Winit-self.

Even if -Winit-self wasn't broken I don't think it applies here,
there's no valid reason to initialize a member with itself, if you
really want to leave a member uninitialized then don't use a
mem-initializer in the constructor (which will work at least until
someone fixes PR c++/2972)

cp/ChangeLog:

? ? ? ?PR c++/18016
? ? ? ?* init.c (perform_member_init): Check for self-initialization.


testsuite/ChangeLog:

? ? ? ?PR c++/18016
? ? ? ?* g++.dg/warn/pr18016.C: New.


tested x86_64-linux with no regressions, ok for trunk?

Attachment: 18016-3.txt
Description: Text document


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