This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Compiler warnings while compiling gcc with clangâ
- From: Trevor Saunders <tbsaunde at tbsaunde dot org>
- To: Renato Golin <renato dot golin at linaro dot org>
- Cc: Andrew Pinski <pinskia at gmail dot com>, Aditya K <hiraditya at msn dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Tue, 5 May 2015 06:23:48 -0400
- Subject: Re: Compiler warnings while compiling gcc with clangâ
- Authentication-results: sourceware.org; auth=none
- References: <BLU179-W15F1B75976EAA6915DFE1BB6D10 at phx dot gbl> <CA+=Sn1k+1NUE_o2mkWRad_-wgQuQCiyHPmNYc00zeH+N61qZXQ at mail dot gmail dot com> <CAMSE1kciuStXmVRor4Mc=qb78xZYarwdHAAz2xme7L00bajWuw at mail dot gmail dot com>
On Tue, May 05, 2015 at 09:00:59AM +0100, Renato Golin wrote:
> On 5 May 2015 at 05:58, Andrew Pinski <pinskia@gmail.com> wrote:
> > These two are bogus and really clang in GCC's mind. The main reason
> > is the standard says struct and class are the same thing.
>
> Apart from the fact that classes are private by default and structs
> are not. They may be similar for layout purposes, and it may be ok to
> interchange them on local re-declarations when the compiler doesn't
> need the type completely defined, but they're not the same thing.
>
> The compiler might be smart and use the protection model that the
> original declaration used (private/public), but what that warning is
> saying is that you have refactored your code to include classes and
> forgot to update all uses, which is a very valid warning. I can't see
> why one would *want* to keep the "struct" keyword. If you're already
> compiling in C++ mode, removing it from variable/argument declarations
> should be valid, and re-declaring incomplete types should be made as
> class.
Saying forward declaration should be done with class is a value choice
you've made. Given forward declarations with struct and class are
interchangable it seems like a perfectly valid choice to me to decide
you don't care to bother fix up all the forward declaration when you
change from class to struct. The warning is useful for people who
care about MSVC compat, or really care about consistancy I guess, but it
seems to me since the code it warns about isn't "wrong" in any real way
the warning doesn't deserve to be in -Wall or really even in -Wextra.
Trev
>
> cheers,
> --renato