This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
please read, any bug with braces
- From: Ales Velebil <velebil dot ales at azd dot cz>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 23 Dec 2004 11:23:05 +0100
- Subject: please read, any bug with braces
Good morning,
I had some bug in my program, corrected, but founded some bug in gcc.
Demonstration of this problem is above.
Thanks for answer
Aleš Velebil
gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I am sorry, for my very very very bad english.
Between this two examples is small difference, but with big differnce in follow-up process
Example1: good version
----------------------------------------------------------------------------------------------------
printf("1");
zaz3=NULL;
for(i=0;i<nalezeno_ffff;i+=(8/velzaz))
for(j=0;j<(8/velzaz);j++)
{
if(zar->archiv_start[i+j]);
{
printf("2");
zaz2=zar->archiv_start[i+j];
if(zaz3)
{
zaz3->next_sprpor=zaz2;
zaz2->prev_sprpor=zaz3;
zaz3=zaz2;
}
else
zar->archiv_zaznamy_sprpor=zaz3=zaz2;
}
}
Output is "1222222222222222222222222222222222222222222222222222222222222222" and continued
Example2: bad version
----------------------------------------------------------------------------------------------------
printf("1");
zaz3=NULL;
for(i=0;i<nalezeno_ffff;i+=(8/velzaz))
for(j=0;j<(8/velzaz);j++)
if(zar->archiv_start[i+j]);
{
printf("2");
zaz2=zar->archiv_start[i+j];
if(zaz3)
{
zaz3->next_sprpor=zaz2;
zaz2->prev_sprpor=zaz3;
zaz3=zaz2;
}
else
zar->archiv_zaznamy_sprpor=zaz3=zaz2;
}
Output is "12" and not continued
----------------------------------------------------------------------------------------------------
there are the same data, it maybe some BUG
difference is between brace after
for(j=0;j<(8/velzaz);j++)
If there are not braces after " for(j=0;j<(8/velzaz);j++) ", then cycle is not functional.
this examples was compiled using this command line:
gcc xxx.c -o xxx -Wall -finline-functions