This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [patch] [C/C++] Add a new warning flag -Wself-assign
> > Given that self-assign is the documented way to suppress a warning
> (for
> > uninitialized variable) is it appropriate for -Wall to turn this on?
> ?It
> > would mean that code that was specifically fixed to avoid warnings
> under
> > -Wall will now get warnings again on that exact same line. ?I don't
> > object to the feature itself, but I do object to that aspect.
> >
>
> This patch actually removes the paragraph in invoke.texi that
> recommends using self-initialization to suppress uninitialized
> variable warnings. Yes, this would be a disruptive change to people
> who use self-initialization, but in my opinion, self-initialization
> doesn't really make sense and is not a good way to fix or work around
> uninitialized variable warnings. (One can initialize a variable with
> other more meaningful value as easily.)
Yes, and that's usually fine. But there is a performance difference -- a small one admittedly. If the initialization is in fact not necessary, then the existing coding convention suppresses the warning with no run-time overhead, while the proposed workaround you describe does have a run-time cost.
paul