Topic: goto
Author: cman@netcom.com (Mike Austin)
Date: Fri, 15 Oct 1993 07:27:28 GMT Raw View
Kin Cho (kin@isi.com) wrote:
: CC j.C
: "j.C", line 2: error: label gotolab undefined
: Compilation failed
goto? They should have killed that thing in C++. #B^)
--
cout << "cman@netcom.com\n";
Author: lenzi@didec18.epfl.ch (Daniel Lenzi)
Date: 15 Oct 1993 10:00:52 GMT Raw View
In article <29krheINNag6@chief.isi.com>, kin@isi.com (Kin Cho) writes:
|> This program compiles and runs fine as a C program but my Sun C++
|> compiler won't compile it as a C++ program:
|>
|> #include <stdio.h>
|> main()
|> {
|> if (1)
|> goto gotolab;
|> if (2)
|> printf("2\n");
|> else
|> gotolab:
|> printf("!2\n");
|> }
|>
|> CC j.C
|> "j.C", line 2: error: label gotolab undefined
|> Compilation failed
|>
|> Is this a cfront bug or an undocumented difference between C and C++?
I experimented a little bit more on different stations and different systems :
here are the results :
DECstation Ultrix: cc (c compiler) : compilation passed
cxx (c++ compiler) : compilation passed
gcc (c compiler) : compilation passed
g++ (c++ compiler) : I don't have it installed
DEC ALPHA OSF/1 : cc : passed
cxx : passed
gcc : passed
g++ : passed
SUN : cc : passed
CC : failed (as you mentioned)
gcc : passed
g++ : passed
VAX/VMS 5.5 : cc (vax C compiler): failed (gotolab : undefined)
gcc : failed (gotolab : undefined)
I dont have any C++ compiler on VAX/VMS
On my surprise, C compilers on VMS both find an error although
C compilers do not complain on UNIX systems.
Well...
Daniel Lenzi
So, no general rules can be found...
Author: rEnE Schmit <rene.schmit@crpht.lu>
Date: 15 Oct 1993 12:48:16 GMT Raw View
In article <cmanCExGpt.G24@netcom.com> Mike Austin, cman@netcom.com
writes:
>Kin Cho (kin@isi.com) wrote:
>: CC j.C
>: "j.C", line 2: error: label gotolab undefined
>: Compilation failed
>
>goto? They should have killed that thing in C++. #B^)
>
Yeah, that's a great idea, let's start another goto war...
rEnE
Author: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Date: Sat, 16 Oct 1993 17:21:03 GMT Raw View
kin@isi.com (Kin Cho) writes:
>This program compiles and runs fine as a C program but my Sun C++
>compiler won't compile it as a C++ program:
>
>#include <stdio.h>
>main()
>{
> if (1)
> goto gotolab;
> if (2)
> printf("2\n");
> else
>gotolab:
> printf("!2\n");
>}
>"j.C", line 2: error: label gotolab undefined
>
>Is this a cfront bug or an undocumented difference between C and C++?
I suspect the former. Cfront is a bit premature at optimizing out
unreachable code before doing any semantic analysis on it - I suspect
that in this case it is "optimizing" out the else clause (including
the label) because it thinks it is unreachable.
--
Fergus Henderson fjh@munta.cs.mu.OZ.AU
Author: kin@isi.com (Kin Cho)
Date: 15 Oct 1993 00:40:14 GMT Raw View
This program compiles and runs fine as a C program but my Sun C++
compiler won't compile it as a C++ program:
#include <stdio.h>
main()
{
if (1)
goto gotolab;
if (2)
printf("2\n");
else
gotolab:
printf("!2\n");
}
CC j.C
"j.C", line 2: error: label gotolab undefined
Compilation failed
Is this a cfront bug or an undocumented difference between C and C++?
--
-kin
Kin Cho, Principal Engineer (408)980-1590 X230 Fax (408)980-0400
Integrated Systems Inc., 3260 Jay Street, Santa Clara, CA 95054