Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 266305

Summary: Requesting additional warnings flags panel for gcc c++
Product: [Tools] CDT Reporter: george lulu <georgebug>
Component: cdt-build-managedAssignee: Marco Stornelli <marco.stornelli>
Status: RESOLVED FIXED QA Contact: Andrew Gvozdev <angvoz.dev>
Severity: enhancement    
Priority: P3 CC: jonah, junk, marco.stornelli, noloader, obusatto
Version: 8.0   
Target Milestone: 9.11.0   
Hardware: PC   
OS: Linux   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=574448
Whiteboard:
Bug Depends on: 365461    
Bug Blocks:    
Attachments:
Description Flags
Adding -Wextra flag to gcc c/c++ settings
none
Adding -Wconversion flag to gcc c/c++ settings none

Description george lulu CLA 2009-02-26 09:25:06 EST
The flags "-Wall -Wextra(alias -W) -pendatic" include the majority of warning messages and improve quality of written significantly through their alerts, to make the writing style of code even more portable and to encourage better writing style I suggest that a seperate panel be listed for the following warnings that are not included in "-Wall -Wextra -pendatic"

These non-optimization related warnings are not included in the flags "-Wall -Wextra -pendatic"

 -Wwrite-strings -Woverloaded-virtual -Weffc++ -Wold-style-cast -Wformat=2 -Wswitch-default -Wswitch-enum -Wunused-parameter -Wfloat-equal -Wcast-qual -Wconversion -Wlogical-op -Waggregate-return -Wmissing-declarations -Wmissing-noreturn  -Wmissing-format-attribute -Wredundant-decls -Wshadow

To even further increase the functionality of the software, the folliwing warnings check boxes could be implemented and could be half-selected(grayed) in the panel when the corresponding -Wall and/or -Wextra function activates them.  For quick reference I've included that section of the manual below.

To easily further increase the functionality, the current as of the implementation of this feature could have hover text that reads from the corresponding definition of the warning flag from the gcc manual page.

Thank you for your time!


-Wall turns on the following warning flags:

          -Waddress   
          -Warray-bounds (only with -O2)  
          -Wc++0x-compat  
          -Wchar-subscripts  
          -Wimplicit-int  
          -Wimplicit-function-declaration  
          -Wcomment  
          -Wformat   
          -Wmain (only for C/ObjC and unless -ffreestanding)  
          -Wmissing-braces  
          -Wnonnull  
          -Wparentheses  
          -Wpointer-sign  
          -Wreorder   
          -Wreturn-type  
          -Wsequence-point  
          -Wsign-compare (only in C++)  
          -Wstrict-aliasing  
          -Wstrict-overflow=1  
          -Wswitch  
          -Wtrigraphs  
          -Wuninitialized (only with -O1 and above)  
          -Wunknown-pragmas  
          -Wunused-function  
          -Wunused-label     
          -Wunused-value     
          -Wunused-variable  

-Wall turns on the following warning flags:          
          -Wclobbered  
          -Wempty-body  
          -Wignored-qualifiers 
          -Wmissing-field-initializers  
          -Wmissing-parameter-type (C only)  
          -Wold-style-declaration (C only)  
          -Woverride-init  
          -Wsign-compare  
          -Wtype-limits  
          -Wuninitialized (only with -O1 and above)
Comment 1 Otavio Pontes CLA 2011-12-02 11:56:43 EST
Created attachment 207852 [details]
Adding -Wextra flag to gcc c/c++ settings
Comment 2 Otavio Pontes CLA 2011-12-02 11:57:35 EST
Created attachment 207854 [details]
Adding -Wconversion flag to gcc c/c++ settings
Comment 3 Otavio Pontes CLA 2011-12-02 11:59:39 EST
I attached 2 patches adding -Wconversion and -Wextra to the compiler settings. This is a quite old bug, anyone know if there is someone working with that?
Comment 4 Andrew Gvozdev CLA 2011-12-02 12:10:19 EST
(In reply to comment #3)
> I attached 2 patches adding -Wconversion and -Wextra to the compiler settings.
> This is a quite old bug, anyone know if there is someone working with that?
We monitor developments on old bugs too. Your patches seem to be a subset of the request in this bug, could you open a new one and attach the patches there?
Comment 5 Otavio Pontes CLA 2011-12-02 12:32:33 EST
(In reply to comment #4)
> (In reply to comment #3)
> > I attached 2 patches adding -Wconversion and -Wextra to the compiler settings.
> > This is a quite old bug, anyone know if there is someone working with that?
> We monitor developments on old bugs too. Your patches seem to be a subset of
> the request in this bug, could you open a new one and attach the patches there?

Sure. I just created a new bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=365461
Comment 6 Jeffrey Walton CLA 2011-12-02 12:50:12 EST
(In reply to comment #0)
> The flags "-Wall -Wextra(alias -W) -pendatic" include the majority of warning
> messages and improve quality of written significantly through their alerts, to
> make the writing style of code even more portable and to encourage better
> writing style I suggest that a seperate panel be listed for the following
> warnings that are not included in "-Wall -Wextra -pendatic"
> 
> These non-optimization related warnings are not included in the flags "-Wall
> -Wextra -pendatic"
> 
>  -Wwrite-strings -Woverloaded-virtual -Weffc++ -Wold-style-cast -Wformat=2
> -Wswitch-default -Wswitch-enum -Wunused-parameter -Wfloat-equal -Wcast-qual
> -Wconversion -Wlogical-op -Waggregate-return -Wmissing-declarations
> -Wmissing-noreturn  -Wmissing-format-attribute -Wredundant-decls -Wshadow
> 
> To even further increase the functionality of the software, the folliwing
> warnings check boxes could be implemented and could be half-selected(grayed) in
> the panel when the corresponding -Wall and/or -Wextra function activates them. 
> For quick reference I've included that section of the manual below.
> 
> To easily further increase the functionality, the current as of the
> implementation of this feature could have hover text that reads from the
> corresponding definition of the warning flag from the gcc manual page.
> 
> Thank you for your time!
Awesome idea - compiler and linker hardening switches are often overlooked.

For C/C++ projects, you might also include -Wformat=2, -Wformat-security and -Wstrict-overflow (GCC 4.2 and later).

Linker hardening would include -Wl,-z,relro -Wl,-z,now and -fPIE.

I'm not holding my breath on linker hardening, but it would be refreshing to see some compiler hardening available and on by default. For those who want to shoot themselves in the foot (by turning off a switch or flag), make them take action to do it.

Jeffrey Walton
Comment 7 me you CLA 2014-11-25 05:30:49 EST
It would be nice to have a panel for arbitrary flags. For example I like to add the -Werror=return-type flag.
Comment 8 Marco Stornelli CLA 2020-01-01 09:47:43 EST
*** Bug 377366 has been marked as a duplicate of this bug. ***