Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
54 user(s) are online (42 user(s) are browsing Forums)

Members: 1
Guests: 53

samo79, more...
Support us!
Recent OS4 Files
OS4Depot.net





Variable defaults
Just popping in
Joined:
2015/9/28 23:42
From Bettendorf, IA, USA
Posts: 215
Is there a command line option for GCC to throw a warning about not setting a variable default?


VOID
MyFunc()
{
Object *Pic;

....
}


Throw a warning since it is not:

Object *Pic=NULL;


I ran into an issue with this that fixed a bug for me. Mine as well set everything, right?

   Report Go to top

Re: Variable defaults
Supreme Council
Joined:
2006/11/19 18:16
From London, England
Posts: 1294
A good starting base is -Wall -Werror -Wwrite-strings

Simon

_________________
Comments made in any post are personal opinion, and are in no-way representative of any commercial entity unless specifically stated as such.
----
http://codebench.co.uk
   Report Go to top

Re: Variable defaults
Just can't stay away
Joined:
2009/5/1 17:57
From Czech Republic
Posts: 1058
@mritter0

The -o3 optimization flag will report a situation when a variable may be used uninitialized.

_________________
Smoke me a kipper, I'll be back for breakfast!

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
   Report Go to top

Re: Variable defaults
Quite a regular
Joined:
2007/7/14 20:30
From Lothric
Posts: 803
@mritter0

https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html some good docs.

CppCheck ( http://cppcheck.net/ ) can do a static analysis that finds also uninitialized variables. G++ doesn't seem to warn about uninitialized class members with -Wall -Wextra but CppCheck can find these, too.

   Report Go to top

Re: Variable defaults
Just popping in
Joined:
2015/9/28 23:42
From Bettendorf, IA, USA
Posts: 215
@all

I use the options you guys posted. I do get the "may" be used uninitialized on occasion. But the problem I fixed, it wasn't reported.

I will check out CppCheck. Thanks.

_________________
Workbench Explorer - A better way to browse drawers
   Report Go to top





[Advanced Search]


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project