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 » Gcc compile option proposal
Gcc compile option proposal [message #39090] Thu, 14 February 2013 19:33 Go to next message
Didier is currently offline  Didier
Messages: 681
Registered: November 2008
Location: France
Contributor
Hi all,

While doing some corrections for MSC on code developped using GCC I noticed that MSC gives an error when we forget to return a value in a function that requires one.

int  myFunction()
{
printf("Hello World !!");
// no return value
}

This code does not compile in MSC while it compile perfectly in GCC when using Theide.

I think we should add the following option to GCC config:
-Werror=return-type

With this GCC and MSC have the same compilation behaviour.
Re: Gcc compile option proposal [message #39094 is a reply to message #39090] Thu, 14 February 2013 20:08 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
Good idea. Will happen...
Re: Gcc compile option proposal [message #39097 is a reply to message #39090] Thu, 14 February 2013 20:46 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

IMHO it would be much more helpful to use "-Wall", but for that we would have to fix tons of warnings inside U++... I am using Clang and even with the default settings for warnings it outputs so many that theide nearly halts just from parsing all the output Clang produces Sad

OTOH Clang could be used to fix the warnings, as it produces hints how to fix each warning and also has option to produce this output in machine readable form, which could be used to automatically correct the sources (with human review afterwards, of course).

Best regards,
Honza

[Updated on: Thu, 14 February 2013 20:47]

Report message to a moderator

Re: Gcc compile option proposal [message #39098 is a reply to message #39097] Thu, 14 February 2013 20:48 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
dolik.rce wrote on Thu, 14 February 2013 14:46

IMHO it would be much more helpful to use "-Wall", but for that we would have to fix tons of warnings inside U++...


...and inside 3rd party sources...
Re: Gcc compile option proposal [message #39099 is a reply to message #39098] Thu, 14 February 2013 21:10 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 681
Registered: November 2008
Location: France
Contributor
Quote:

but for that we would have to fix tons of warnings inside U++

Yes I am perfectly aware of that

Quote:

theide nearly halts just from parsing all the output

That's why -Wall may not be such a good idea.
Re: Gcc compile option proposal [message #39100 is a reply to message #39099] Thu, 14 February 2013 21:52 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Didier wrote on Thu, 14 February 2013 21:10

Quote:

theide nearly halts just from parsing all the output

That's why -Wall may not be such a good idea.
This happens to me on default setting WITHOUT -Wall...

Quote:

...and inside 3rd party sources...

Even fixing only the U++ sources would be great improvement. I don't really care about how many warnings is in sources of plugin/* packages. What drives me mad is the warnings that come from the headers that I include in my package, because they are making it harder to notice warnings regarding my code. I believe (but I might be wrong) that there will not be many warnings in the 3rd party headers, at least compared to U++ headers (because there is so many of them in single compilation unit, esp. with BLITZ).


I am well aware that this discussion happened already many times on this forum and that nothing will probably happen this time as ussualy... but I have to at least try to convince you Smile

Honza
Re: Gcc compile option proposal [message #39101 is a reply to message #39100] Thu, 14 February 2013 23:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
/home/cxl/upp.src/uppsrc/Core/CharSet.h:119:54: warning: '&&' within '||' [-Wlogical-op-parentheses]
inline bool IsAlpha(int c)         { return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z'; }
                                            ~~~~~~~~~^~~~~~~~~~~ ~~
/home/cxl/upp.src/uppsrc/Core/CharSet.h:119:54: note: place parentheses around the '&&' expression to silence this warning


Go to hell with this... I am not going to make the code unreadable.

Plus, I have a very intense feeling that even if I would screw the code and added parenthesis in this situation, one or two years later somebody would get a nice idea that there are more needed around c >= 'A' etc...

Mirek

[Updated on: Thu, 14 February 2013 23:07]

Report message to a moderator

Re: Gcc compile option proposal [message #39102 is a reply to message #39100] Thu, 14 February 2013 23:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
dolik.rce wrote on Thu, 14 February 2013 15:52


I am well aware that this discussion happened already many times on this forum and that nothing will probably happen this time as ussualy... but I have to at least try to convince you Smile

Honza


It is not true that nothing happened in the past. A couple of years ago, U++ was made GCC/-Wall (mostly) free. Since then -Wall was extended...

(I have also refused to fix 3rd party sources).

It is also BTW impossible to activate full MSC warnings, because they demand "safe" replacement for standard C library functions like strcpy, but those replacements are MSC specific.

Mirek
Re: Gcc compile option proposal [message #39103 is a reply to message #39102] Thu, 14 February 2013 23:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
Hm, now I have checked and I am actually compiling with

-Wall -Wno-parentheses

so except that (&&) warning, which I consider really way too stupid, we are -Wall compliant.
Re: Gcc compile option proposal [message #39104 is a reply to message #39103] Fri, 15 February 2013 07:41 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

mirek wrote on Thu, 14 February 2013 23:31

Hm, now I have checked and I am actually compiling with

-Wall -Wno-parentheses

so except that (&&) warning, which I consider really way too stupid, we are -Wall compliant.

OK, I could live with blacklisting the parentheses warnings. Other than that, my gcc 4.7.2 reports only one error in theide:
Quote:


/home/h/upp-production/uppsrc/ide/Help.cpp:581:10: warning: converting ‘false’ to pointer type ‘IdeDesigner*’ [-Wconversion-null]


With clang, it is bit worse:

$ umk uppsrc AllForI18n CLANG -ba | grep 'warning:' | sort -u | grep -o '\[-W.*\

' | sort | uniq -c | sort -rn"
88 [-Wlogical-op-parentheses] *
40 [-Wdangling-else] *
16 [-Woverloaded-virtual]
3 [-Wunused-private-field]
1 [-Wbitwise-op-parentheses] *
1 [-Wbool-conversion] *
1 [-Winvalid-source-encoding] *
1 [-Wmismatched-tags] *
1 [-Wtautological-compare]
1 [-Wunneeded-internal-declaration]
Items marked with * are present by default, even without -Wall option. Numbers represents unique occurrences, the actual counts of the errors in output is even higher.

At least some of them should be fixed. I'll gladly volunteer Wink

Honza
Re: Gcc compile option proposal [message #39105 is a reply to message #39104] Fri, 15 February 2013 08:33 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
dolik.rce wrote on Fri, 15 February 2013 01:41

mirek wrote on Thu, 14 February 2013 23:31

Hm, now I have checked and I am actually compiling with

-Wall -Wno-parentheses

so except that (&&) warning, which I consider really way too stupid, we are -Wall compliant.

OK, I could live with blacklisting the parentheses warnings. Other than that, my gcc 4.7.2 reports only one error in theide:
Quote:


/home/h/upp-production/uppsrc/ide/Help.cpp:581:10: warning: converting �false� to pointer type �IdeDesigner*� [-Wconversion-null]


With clang, it is bit worse:



Which IMO nicely demonstrates my point. We can "fix" them, but are we going to forever keep changing standard compliant and fairly tested code only because some compiler developer has a little bit different taste for what deserves warning?

(That said, I will go through CLANG warnings anyway to see if there is something I am willing to fix...)
Re: Gcc compile option proposal [message #39106 is a reply to message #39105] Fri, 15 February 2013 11:11 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

mirek wrote on Fri, 15 February 2013 02:33


Which IMO nicely demonstrates my point. We can "fix" them, but are we going to forever keep changing standard compliant and fairly tested code only because some compiler developer has a little bit different taste for what deserves warning?


Some warnings are simply stupid and this one particularly (one is not using parenthesis because operator precedence rule exists). It should rather be moved to "--best-practices" compiler switch if it existed Wink
Re: Gcc compile option proposal [message #39108 is a reply to message #39106] Fri, 15 February 2013 17:50 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 681
Registered: November 2008
Location: France
Contributor
Hi all,

I didn't expect so much passion over such a simple post

Shocked Shocked Shocked

But my fisrt post was more about converting a warning into an error rather purly warnings
Re: Gcc compile option proposal [message #39110 is a reply to message #39090] Fri, 15 February 2013 19:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
I have tried to fix warnings for clang 3.0 (which is default package version for my distro), except that one terror and 3rd party, so for me

clang -Weverything -Wno-parentheses

now compiles without warnings.
Re: Gcc compile option proposal [message #39114 is a reply to message #39097] Sat, 16 February 2013 11:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
dolik.rce wrote on Thu, 14 February 2013 14:46

IMHO it would be much more helpful to use "-Wall", but for that we would have to fix tons of warnings inside U++... I am using Clang and even with the default settings for warnings it outputs so many that theide nearly halts just from parsing all the output Clang produces Sad



Well, one positive outcome is that I have investigated this choking and optimized it out Smile

Mirek
Re: Gcc compile option proposal [message #39115 is a reply to message #39108] Sat, 16 February 2013 17:29 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Didier wrote on Fri, 15 February 2013 08:50

But my fisrt post was more about converting a warning into an error rather purly warnings


If a function should return a value and does not it should throw an error. A default value in a users code if the function for some reason does not come up with one.

I don't understand other options in this thread but it makes my head hurt.
Re: Gcc compile option proposal [message #39117 is a reply to message #39108] Sat, 16 February 2013 18:28 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
Didier wrote on Fri, 15 February 2013 11:50

Hi all,

I didn't expect so much passion over such a simple post

Shocked Shocked Shocked

But my fisrt post was more about converting a warning into an error rather purly warnings


Well, in fact, it is rather configuration issue, you can configure your build method now. (But I plan to make such config default..)
Re: Gcc compile option proposal [message #39130 is a reply to message #39114] Sun, 17 February 2013 17:50 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

mirek wrote on Sat, 16 February 2013 11:16

dolik.rce wrote on Thu, 14 February 2013 14:46

IMHO it would be much more helpful to use "-Wall", but for that we would have to fix tons of warnings inside U++... I am using Clang and even with the default settings for warnings it outputs so many that theide nearly halts just from parsing all the output Clang produces Sad



Well, one positive outcome is that I have investigated this choking and optimized it out Smile

Mirek



Great, thank you. It is really appreciated...

mirek wrote on Sat, 16 February 2013 11:16

dolik.rce wrote on Thu, 14 February 2013 14:46

IMHO it would be much more helpful to use "-Wall", but for that we would have to fix tons of warnings inside U++... I am using Clang and even with the default settings for warnings it outputs so many that theide nearly halts just from parsing all the output Clang produces Sad



Well, one positive outcome is that I have investigated this choking and optimized it out Smile

Mirek



... as well as this one.

Best regards,
Honza
Previous Topic: Request: completion 64 bit support in Draw and Stream
Next Topic: Core/Rpc and VC 2012
Goto Forum:
  


Current Time: Fri Jun 21 00:30:29 CEST 2024

Total time taken to generate the page: 0.01475 seconds