|
|
Home » U++ Library support » U++ Core » Gcc compile option proposal
Gcc compile option proposal [message #39090] |
Thu, 14 February 2013 19:33  |
Didier
Messages: 725 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:
With this GCC and MSC have the same compilation behaviour.
|
|
|
|
Re: Gcc compile option proposal [message #39097 is a reply to message #39090] |
Thu, 14 February 2013 20: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 
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 #39100 is a reply to message #39099] |
Thu, 14 February 2013 21:52   |
|
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
Honza
|
|
|
Re: Gcc compile option proposal [message #39101 is a reply to message #39100] |
Thu, 14 February 2013 23:01   |
 |
mirek
Messages: 14255 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 #39104 is a reply to message #39103] |
Fri, 15 February 2013 07: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:
$ 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 
Honza
|
|
|
Re: Gcc compile option proposal [message #39105 is a reply to message #39104] |
Fri, 15 February 2013 08:33   |
 |
mirek
Messages: 14255 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   |
|
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 
|
|
|
|
|
|
|
|
Re: Gcc compile option proposal [message #39130 is a reply to message #39114] |
Sun, 17 February 2013 17:50  |
|
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 
|
Well, one positive outcome is that I have investigated this choking and optimized it out 
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 
|
Well, one positive outcome is that I have investigated this choking and optimized it out 
Mirek
|
... as well as this one.
Best regards,
Honza
|
|
|
Goto Forum:
Current Time: Tue Apr 29 11:18:58 CEST 2025
Total time taken to generate the page: 0.06761 seconds
|
|
|