Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Problem with gcc compilers and -Wall
Problem with gcc compilers and -Wall [message #28589] Wed, 08 September 2010 09:03 Go to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Mirek

In some recent posts it has been oberrved that code compiled with gcc/minqw had non void functions without a return.

This problem is easy to have and produce strange errors.

It would be great if you could add "-Wreturn-type" parameter when using gcc/mingw compiler.

In the same way, the "-Wall" could be considered. Perhaps it is pedantic, but it make sense as many little warnings can produce weird errors.


Best regards
Iñaki
Re: Problem with gcc compilers and -Wall [message #28613 is a reply to message #28589] Wed, 08 September 2010 10:58 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Koldo!

I believe that -Wall is overkill. Unless you want to add all those missing parentheses around && within || (which is the most common warning I think) to make the output at least a little bit readable Wink Also there is a lot of warnings in 3rd party code in plugin directory, which obscure the output (even without -Wall).

I think that it should be up to the user to set up how pedantic should the compiler be. It is just a matter of writing the options into the build method setting. At least for debug mode, it is more difficult for release mode, but possible too and seeing the warnings in debug mode should be enough anyway.

Best regards,
Honza
Re: Problem with gcc compilers and -Wall [message #28616 is a reply to message #28613] Wed, 08 September 2010 11:12 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello Honza

Perhaps "-Wall" is pedantic. However I have seen this week two errors because not using "-Wreturn-type" in Forum and at home Smile.

I think "-Wreturn-type" (and perhaps other) should be included as it is more than a warning. It causes weird errors.

In fact, I captured this error because MSC detects it (and I always test the apps with two compilers just in case Smile ).


Best regards
Iñaki
Re: Problem with gcc compilers and -Wall [message #28644 is a reply to message #28589] Thu, 09 September 2010 09:33 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
-Wall is the first thing I set up before creating new project.
It's never an overkill. (ok, I know 1 or 2 type of warnings which are really not helpful because I never made such error they warn against and use that deliberately, but 99% of -Wall are valid objections and code can be improved)

edit:
"I think that it should be up to the user to set up how pedantic should the compiler be."

Of course, but that means that the upp core should be very shy when compiled with -Wall to not disturb. Wink

[Updated on: Thu, 09 September 2010 09:35]

Report message to a moderator

Re: Problem with gcc compilers and -Wall [message #28647 is a reply to message #28589] Thu, 09 September 2010 10:13 Go to previous messageGo to next message
jerson is currently offline  jerson
Messages: 202
Registered: June 2010
Location: Bombay, India
Experienced Member

How do I set this -Wall option or the -Wreturn-type in my IDE? Perhaps it is wise to do this as a newbie.
Re: Problem with gcc compilers and -Wall [message #28648 is a reply to message #28589] Thu, 09 September 2010 10:15 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
I'm using Setup/Build methods - Debug options.
Re: Problem with gcc compilers and -Wall [message #28650 is a reply to message #28644] Thu, 09 September 2010 10:22 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

mr_ped wrote on Thu, 09 September 2010 09:33

Of course, but that means that the upp core should be very shy when compiled with -Wall to not disturb. Wink

You are right about this Ped. Maybe if the Core didn't put out so many useless warning I would use the option sometimes too. I guess we should fill in those missing brackets and parenthesis...

Honza
Re: Problem with gcc compilers and -Wall [message #28652 is a reply to message #28650] Thu, 09 September 2010 10:51 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
dolik.rce wrote on Thu, 09 September 2010 10:22

mr_ped wrote on Thu, 09 September 2010 09:33

Of course, but that means that the upp core should be very shy when compiled with -Wall to not disturb. Wink

You are right about this Ped. Maybe if the Core didn't put out so many useless warning I would use the option sometimes too. I guess we should fill in those missing brackets and parenthesis...

Honza

Smile!


Best regards
Iñaki
Re: Problem with gcc compilers and -Wall [message #28659 is a reply to message #28650] Thu, 09 September 2010 18:58 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
dolik.rce wrote on Thu, 09 September 2010 10:22

mr_ped wrote on Thu, 09 September 2010 09:33

Of course, but that means that the upp core should be very shy when compiled with -Wall to not disturb. Wink

You are right about this Ped. Maybe if the Core didn't put out so many useless warning I would use the option sometimes too. I guess we should fill in those missing brackets and parenthesis...

Honza


Mirek was against that. Smile (I did push him into fixing lot of warning a 1-1.5 year ago, but he didn't like the additional () ... well, after all, he *is* C++ developer, so he does remember operators priority. I put () everywhere and don't care, I know I will never learn C++ fully. Very Happy )
Re: Problem with gcc compilers and -Wall [message #28660 is a reply to message #28659] Thu, 09 September 2010 21:45 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Well, then maybe -Wall -Wno-parentheses? BTW: I always thought that those extra parentheses are suggested to prevent trouble in case someone writes non-conforming compiler Smile

Also -Wno-reorder would be nice, but that would have to be set only for C++, for C files it prints out warning.

Looking at the warnings, I observed following:

There is a lot of unused-variable warnings and few unused-function. Those could be fixed easily and it might improve readability.

There are some warnings that sound pretty dangerous. Like uninitialized variables. Or even more terrifying "operation on ‘q’ may be undefined". It is not that bad in the end, it belongs to the code that is bit messy, but probably OK (as far as I can tell Smile ):
q = q > 0 ? d.name.ReverseFind(':', q) : q = d.name.ReverseFind(':');


There is also few really stupid warnings. Like "‘main’ is usually a function". I believe you don't have to be C++ wizard to know that Very Happy

Honza
Re: Problem with gcc compilers and -Wall [message #28662 is a reply to message #28589] Fri, 10 September 2010 05:11 Go to previous messageGo to next message
jerson is currently offline  jerson
Messages: 202
Registered: June 2010
Location: Bombay, India
Experienced Member

IMO, the warnings should be eliminated altogether if they can be. It gets messy for newbies to sift through the warnings and know which are caused by their own follies.

If it doesn't break the IDE functionality, I'd say, fix it please.
Re: Problem with gcc compilers and -Wall [message #28669 is a reply to message #28662] Fri, 10 September 2010 12:45 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Maybe we could (optionally) silence (-Wno-xxx) the most common errors in U++ code (that is anything that is in uppsrc nest) and let the user control the verbosity for his portion of code, defaulting to -Wall. But IMHO that is far too fine grained and I would rather prefer adding those parentheses etc. into the code...

Honza
Re: Problem with gcc compilers and -Wall [message #28732 is a reply to message #28669] Tue, 14 September 2010 11:04 Go to previous message
mdelfede is currently offline  mdelfede
Messages: 1307
Registered: September 2007
Ultimate Contributor
I agree too with -Wall.... It helps writing bugfree code many times.
I also had an error of function with missing return at end, giving weird errors and I could locate it just compiling with MSC which has the warning enabled.
I think that the -Wall with -Wno-parentheses would be the best choice... and I think it would not require too many "fixes" in Upp sources.

Max
Previous Topic: Is there way to get subrange of a vector quickly?
Next Topic: Is there linked list in u++?
Goto Forum:
  


Current Time: Thu Mar 28 22:12:48 CET 2024

Total time taken to generate the page: 0.01630 seconds