This is the mail archive of the 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: Enable -Wreturn-type by default ?

On Sun, 17 Nov 2013, Marc Glisse wrote:

> On Sun, 17 Nov 2013, Sylvestre Ledru wrote:
> > On 17/11/2013 06:03, Alec Teal wrote:
> > > I do hope Clang ('though I don't use it) doesn't make it an error
> > > because not all functions have to return in C iirc.
> > It does.
> > It makes 120 packages fail to build from source in Debian (on 18854
> > packages):
> >
> That's cool, if clang forces people to update their code to C99, maybe we'll
> be able to switch gcc to use -std=gnu99 by default one day...

Any GCC release always requires some third-party code that was doing 
dubious things to be updated to work with changes in GCC - the extent of 
such code may be indicative of whether a change can be made to GCC (and 
how hard it is to fix the third-party code may help indicate whether GCC 
needs to be more relaxed in a particular case, e.g. making something a 
pedwarn-if-pedantic rather than a hard error) but doesn't determine it.

I think people quite commonly use -pedantic with GCC in its default 
(-std=gnu89) mode to get warnings about C99 features creeping into their 
code if they want to keep it compilable without needing a C99 compiler.  
With a default of -std=gnu99, -pedantic would no longer give those 
warnings and they'd need to make the previous default -std=gnu89 explicit 
to get them.  I think we should provide a better solution for such users 
to get those warnings without changing the selected language versions - 
that is, options to warn about C90/C99 and C99/C11 compatibility issues in 
the cases where we presently give pedwarns (occasionally warnings, in 
particular for format checking) if pedantic and in C90/C99 mode.  (The 
diagnostics would be pedwarns or warnings as appropriate for the language 
version.  See pedwarn_c90.)  Bug 51849.

Given such -Wc90-c99-compat and -Wc99-c11-compat options, I think we could 
move the default straight to -std=gnu11, C11 support now being 
substantially on par with C99 support.  (I still need to update 
implement-c.texi for C11 and some other bits of documentation for the 
state of C99 and C11 support, but that doesn't need to be done in 
development stage 1.  And release notes are still needed for for _Generic, 
_Atomic and _Thread_local support.)

Joseph S. Myers

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