Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
151 user(s) are online (79 user(s) are browsing Forums)

Members: 0
Guests: 151

more...

Headlines

 
  Register To Post  

Variable defaults
Just popping in
Just popping in


See User information
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?

Go to top
Re: Variable defaults
Supreme Council
Supreme Council


See User information
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
Go to top
Re: Variable defaults
Just can't stay away
Just can't stay away


See User information
@mritter0

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

The Rear Window blog

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
Go to top
Re: Variable defaults
Just can't stay away
Just can't stay away


See User information
@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.

Go to top
Re: Variable defaults
Just popping in
Just popping in


See User information
@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
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project