[Sunhelp] ?: a great different compiling between C++ 4.1 and C++ 5.0

Wonkyu Chang - Sun Korea SE Wonkyu.Chang at Korea.Sun.COM
Mon Dec 20 21:05:47 CST 1999


Dear experts,

When my customer compiled the some source code with C++ compiler,
he got quite different results.

The details was described as followings, the source code was
extracted as a part of original critical source.

What do you think about it?

The following is C++ source code with "src.cpp" as file name.

[cnt01:/export/home/koscom] cat src.cpp
#include <stdio.h>

int main()
{
    for(int i =0; i<10; i++) {
        printf("test[%d]\n", i);
    }
    for(i =0; i<10; i++) {
        printf("sssssss[%d]\n", i);
    }
    printf("aaaaaaaaaaa[%d]\n", i);
}

He compiled it with C++ 4.1 compiler, 
and get the results as like followings.

[cnt01:/export/home/koscom] CC -o out1 src.cpp
[cnt01:/export/home/koscom] out1
test[0]
test[1]
test[2]
test[3]
test[4]
test[5]
test[6]
test[7]
test[8]
test[9]
sssssss[0]
sssssss[1]
sssssss[2]
sssssss[3]
sssssss[4]
sssssss[5]
sssssss[6]
sssssss[7]
sssssss[8]
sssssss[9]
aaaaaaaaaaa[10]

But, when he compiled it with C++ 5.0,
and he got the below error message.

[SVP:/usr5/astock] CC -o out2 src.cpp
"1.cpp", line 8: Error: i is not defined.
"1.cpp", line 8: Error: i is not defined.
"1.cpp", line 8: Error: i is not defined.
"1.cpp", line 9: Error: i is not defined.
"1.cpp", line 11: Error: i is not defined.
5 Error(s) detected.


Thanks in advance,
WK Chang








More information about the SunHELP mailing list