This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

preprocessor/5520: There's a warning I miss with "if{} else{}" statement



>Number:         5520
>Category:       preprocessor
>Synopsis:       There's a warning I miss with "if{} else{}" statement
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 28 15:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Pierre Chatelier
>Release:        gcc 3.0.3
>Organization:
>Environment:
DOS (DJGPP)
>Description:
I think a warning shoul be raised when someone writes
if (condition);
{
}

instead of
if (condition)
{
}

(===== Watch at the ";" ====)

Actually, it can only be a mistake, and that's a pity it's not detected. It drives to severe bugs.

>How-To-Repeat:
int x=1;
if (x == 0);
{
   cout << "x equals zero" << endl;
}
>Fix:
int x=1;
if (x == 0)
{
   cout << "x equals zero" << endl;
}
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]