Hi all,
recently encounter following bugs:
if (a b); //<- bug in the careless ";" here
return 0;
Due to the extra ";" in the if statement line, it always return 0.
Anyone know g++ has any compiler - warning flag to detect this kind of
error? if not, is it any source code checking tools can do it ?
thanks,
Eric. 6 1756
lasing wrote:
recently encounter following bugs:
if (a b); //<- bug in the careless ";" here
return 0;
Due to the extra ";" in the if statement line, it always return 0.
Anyone know g++ has any compiler - warning flag to detect this kind of
error?
You need to ask in the compiler newsgroup about the settings for
any particular compiler. This is not a C++ language question.
if not, is it any source code checking tools can do it ?
I bet PC-lint can do it. [I just checked, it does: Info 721] http://gimpel-online.com/MsgRef.html#721
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
On 2007-08-16 14:39, lasing wrote:
Hi all,
recently encounter following bugs:
if (a b); //<- bug in the careless ";" here
return 0;
Due to the extra ";" in the if statement line, it always return 0.
Anyone know g++ has any compiler - warning flag to detect this kind of
error? if not, is it any source code checking tools can do it ?
Not really what you asked for, but if your editor can indent the files
you work on, use that function, 'return 0;' will then be on the same
level as the if-statement which should make you suspicious.
--
Erik Wikström
Hi!
lasing schrieb:
Anyone know g++ has any compiler - warning flag to detect this kind of
error? if not, is it any source code checking tools can do it ?
My gcc manual tells me it is covered by "-Wextra". But in practice my
g++ 4.1.2 does not complain about it -.-
Frank
lasing <yu******@gmail .comwrote in message...
Hi all,
recently encounter following bugs:
if (a b); file://<- bug in the careless ";" here
return 0;
Due to the extra ";" in the if statement line, it always return 0.
Anyone know g++ has any compiler - warning flag to detect this kind of
error? if not, is it any source code checking tools can do it ?
thanks, Eric.
Change your bad habits. If you get in the habit of always using
curly-braces, you will save yourself some of the 'gotchas'.
if( b ){}
if( a b ){ return 0; }
if( a b ){} else{ /* stuff */ }
for( /* .... */ ){}
for( /* .... */ ){ /* stuff */ }
while( a b ){ /* stuff */; ++b; }
while( /* something */ ){ ; } // if that's what you intended.
etc.
--
Bob R
POVrookie
BobR wrote:
lasing <yu******@gmail .comwrote in message...
>Hi all,
recently encounter following bugs:
if (a b); file://<- bug in the careless ";" here return 0;
Due to the extra ";" in the if statement line, it always return 0.
Anyone know g++ has any compiler - warning flag to detect this kind of error? if not, is it any source code checking tools can do it ? thanks, Eric.
Change your bad habits. If you get in the habit of always using
curly-braces, you will save yourself some of the 'gotchas'.
if( b ){}
if( a b ){ return 0; }
if( a b ){} else{ /* stuff */ }
for( /* .... */ ){}
for( /* .... */ ){ /* stuff */ }
while( a b ){ /* stuff */; ++b; }
while( /* something */ ){ ; } // if that's what you intended.
etc.
How does that help?
if (somefunkycondi tion);
{
/* plenty of stuff in curly braces */
}
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Victor Bazarov <v.********@com Acast.netwrote in message...
>
How does that help?
if (somefunkycondi tion);
{
/* plenty of stuff in curly braces */
}
So sorry I tried to suggest something. I'll refrain from such in the future!
[ Beam me up Scottie! There is no intelligent life on Earth. ]
--
Bob R
POVrookie This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Richard |
last post by:
How do I prevent a submit action from occurring if the select
box has no value.
The box is for a database search where the user must enter
a keyword. Leaving the box empty triggers a blanket search
of the database and uses lots of processing time and gives too
many results. Is there something I can add to the submit button
to trap an empty select box and trigger a warning that something
must be entered?
<input type=hidden name="action"...
|
by: Michel Bany |
last post by:
I am trying to parse responseXML from an HTTP request.
var doc = request.responseXML;
var elements = doc.getElementsByTagName("*");
the last statement returns an empty collection when running from IE6.
It returns the expected collection when running under Firefox or Mozilla.
Anybody can explain ?
Michel.
|
by: MK |
last post by:
I am a newbie. Please help. The following warning is issued by gcc-3.2.2
compiler (pc Linux):
==================================================================
read_raw_data.c:51: warning: assignment makes pointer from integer
without a cast
==================================================================
when the following piece of code was compiled. The offending statement
is calloc. A similar statement in the main() function...
|
by: Dan |
last post by:
Hi,
I have a problem using an aspx page with a Control on it. I get the
following error message
Compiler Error Message: CS1595: 'Test.Class2' is defined in multiple
places; using definition from
'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET
Files\root\1f575646\ad3a161b\assembly\dl2\57ca505e\044565c0_f84fc401\Test1.DLL'
The problem is that the control is defined in two different assemblies
|
by: Aaron |
last post by:
Hello all,
I have 5 warnings only but I want to know how to "optimize" my code so that
it is "clean."
The warning is this with all 5 the same
Warning 1 Variable 'strxxx' is used before it has been assigned a value. A
null reference exception could result at runtime.
Here is the code
| |
by: alban |
last post by:
Hello
I have got some problems of compilation on a AIX IBM,
I use the XLC compilator (And I can't install another one).
I try to compile code Pro*c ".pc" (oracle), I need do a pre-compilation
after the pre-compilation with the my makefile I get the files ".c"
After this a get also the objects files ".o", but no linkage ! and I can't have the exec file !
I have got some errors how I dont understand really :
|
by: Terry |
last post by:
I am getting the following warning for the below function. I understand what
it means but how do I handle a null reference? Then how do I pass the
resulting value?
Regards
Warning 1 Function 'Dec2hms' doesn't return a value on all code paths. A
null reference exception could occur at run time when the result is used.
|
by: subramanian |
last post by:
Consider the following program:
#include <stdio.h>
void myfn(const int **a)
{
static int i, j, k;
a = &i;
a = &j;
|
by: Subrat |
last post by:
Hello,
I am getting complation warning saying,
warning : returning reference to temporary.
The code from which it is coming:
vector<boola_oObj;
This vector is filled with all boolean values
Then when I want to check a condition on this
for loop
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |