Connecting Tech Pros Worldwide Help | Site Map

Intel C++ 8.0 : declaration hides declaration

Alex Vinokur
Guest
 
Posts: n/a
#1: Jul 22 '05
===========
Windows 2000
Intel C++ 8.0
===========

------ foo.cpp ------
int main ()
{
for (int i = 0; i < 10; i++);
for (int i = 0; i < 10; i++);
return 0;
}
---------------------

--- Compilation ---

$ icl foo.cpp

Intel(R) C++ Compiler for 32-bit applications, Version 8.0 Build 20031017Z Package ID: W_CC_P_8.0.040
Copyright (C) 1985-2003 Intel Corporation. All rights reserved.
30 DAY EVALUATION LICENSE

foo.cpp
icl: NOTE: The evaluation period for this product ends on 16-apr-2004 UTC.
foo.cpp(4): warning #1420: declaration in for-initializer hides a declaration in the surrounding scope
the hidden declaration is at line 3
for (int i = 0; i < 10; i++);
^

foo.cpp(4): warning #1429: variable declaration hides declaration in for-initializer
the hidden declaration is at line 3
for (int i = 0; i < 10; i++);
^

Microsoft (R) Incremental Linker Version 7.00.9466
Copyright (C) Microsoft Corporation. All rights reserved.

-out:foo.exe
foo.obj

-------------------

Why does Intel C++ 8.0 produce the warnings?

--
Alex Vinokur
mailto:alexvn@connect.to
http://mathforum.org/library/view/10978.html





Chuck McDevitt
Guest
 
Posts: n/a
#2: Jul 22 '05

re: Intel C++ 8.0 : declaration hides declaration



"Alex Vinokur" <alexvn@big.foot.com> wrote in message
news:c4qu9m$2kb9ao$1@ID-79865.news.uni-berlin.de...[color=blue]
> ===========
> Windows 2000
> Intel C++ 8.0
> ===========
>
> ------ foo.cpp ------
> int main ()
> {
> for (int i = 0; i < 10; i++);
> for (int i = 0; i < 10; i++);
> return 0;
> }
> ---------------------
>
> --- Compilation ---
>
> $ icl foo.cpp
>
> Intel(R) C++ Compiler for 32-bit applications, Version 8.0 Build
> 20031017Z Package ID: W_CC_P_8.0.040
> Copyright (C) 1985-2003 Intel Corporation. All rights reserved.
> 30 DAY EVALUATION LICENSE
>
> foo.cpp
> icl: NOTE: The evaluation period for this product ends on 16-apr-2004 UTC.
> foo.cpp(4): warning #1420: declaration in for-initializer hides a
> declaration in the surrounding scope
> the hidden declaration is at line 3
> for (int i = 0; i < 10; i++);
> ^
>
> foo.cpp(4): warning #1429: variable declaration hides declaration in
> for-initializer
> the hidden declaration is at line 3
> for (int i = 0; i < 10; i++);
> ^
>
> Microsoft (R) Incremental Linker Version 7.00.9466
> Copyright (C) Microsoft Corporation. All rights reserved.
>
> -out:foo.exe
> foo.obj
>
> -------------------
>
> Why does Intel C++ 8.0 produce the warnings?
>
> --[/color]

It's a bug. Intel C++ 8.0 is handling the for loop scoping in the old way,
where the variable declared in the for loop would still be in-scope after
the loop exits.
Microsoft Visual C++ used to do this as well, and still does it if you don't
tell it you want "Conforming" behaviour for for-loops. Perhaps Intel C++
8.0 has an option for this?

Anyway, you can always add extra braces:

int main ()
{
{for (int i = 0; i < 10; i++);}
{for (int i = 0; i < 10; i++);}
return 0;
}

That will make the warning go away.




Chuck McDevitt
Guest
 
Posts: n/a
#3: Jul 22 '05

re: Intel C++ 8.0 : declaration hides declaration



"Alex Vinokur" <alexvn@big.foot.com> wrote in message
news:c4qu9m$2kb9ao$1@ID-79865.news.uni-berlin.de...[color=blue]
> ===========
> Windows 2000
> Intel C++ 8.0
> ===========
>
> ------ foo.cpp ------
> int main ()
> {
> for (int i = 0; i < 10; i++);
> for (int i = 0; i < 10; i++);
> return 0;
> }
> ---------------------
>
> --- Compilation ---
>
> $ icl foo.cpp
>
> Intel(R) C++ Compiler for 32-bit applications, Version 8.0 Build
> 20031017Z Package ID: W_CC_P_8.0.040
> Copyright (C) 1985-2003 Intel Corporation. All rights reserved.
> 30 DAY EVALUATION LICENSE
>
> foo.cpp
> icl: NOTE: The evaluation period for this product ends on 16-apr-2004 UTC.
> foo.cpp(4): warning #1420: declaration in for-initializer hides a
> declaration in the surrounding scope
> the hidden declaration is at line 3
> for (int i = 0; i < 10; i++);
> ^
>
> foo.cpp(4): warning #1429: variable declaration hides declaration in
> for-initializer
> the hidden declaration is at line 3
> for (int i = 0; i < 10; i++);
> ^
>
> Microsoft (R) Incremental Linker Version 7.00.9466
> Copyright (C) Microsoft Corporation. All rights reserved.
>
> -out:foo.exe
> foo.obj
>
> -------------------
>
> Why does Intel C++ 8.0 produce the warnings?
>
> --[/color]

It's a bug. Intel C++ 8.0 is handling the for loop scoping in the old way,
where the variable declared in the for loop would still be in-scope after
the loop exits.
Microsoft Visual C++ used to do this as well, and still does it if you don't
tell it you want "Conforming" behaviour for for-loops. Perhaps Intel C++
8.0 has an option for this?

Anyway, you can always add extra braces:

int main ()
{
{for (int i = 0; i < 10; i++);}
{for (int i = 0; i < 10; i++);}
return 0;
}

That will make the warning go away.




Jonathan Turkanis
Guest
 
Posts: n/a
#4: Jul 22 '05

re: Intel C++ 8.0 : declaration hides declaration



"Chuck McDevitt" <Chuck_McDevitt@c-o-m-c-a-s-t.net> wrote in message
news:Ddccc.78943$JO3.41863@attbi_s04...[color=blue]
>[/color]

[color=blue]
>
> It's a bug. Intel C++ 8.0 is handling the for loop scoping in the[/color]
old way,[color=blue]
> where the variable declared in the for loop would still be in-scope[/color]
after[color=blue]
> the loop exits.
> Microsoft Visual C++ used to do this as well, and still does it if[/color]
you don't[color=blue]
> tell it you want "Conforming" behaviour for for-loops. Perhaps[/color]
Intel C++[color=blue]
> 8.0 has an option for this?[/color]

Here are the relevant options, from the Intel manual:

/Zc:forScope - enforce standard behavior for initializers of loops
/Za - Enforces strict conformance to the ANSI standard
for C
/Qms0 - Instructs the compiler to disable Microsoft
compatibility bugs.

Jonathan


Jonathan Turkanis
Guest
 
Posts: n/a
#5: Jul 22 '05

re: Intel C++ 8.0 : declaration hides declaration



"Chuck McDevitt" <Chuck_McDevitt@c-o-m-c-a-s-t.net> wrote in message
news:Ddccc.78943$JO3.41863@attbi_s04...[color=blue]
>[/color]

[color=blue]
>
> It's a bug. Intel C++ 8.0 is handling the for loop scoping in the[/color]
old way,[color=blue]
> where the variable declared in the for loop would still be in-scope[/color]
after[color=blue]
> the loop exits.
> Microsoft Visual C++ used to do this as well, and still does it if[/color]
you don't[color=blue]
> tell it you want "Conforming" behaviour for for-loops. Perhaps[/color]
Intel C++[color=blue]
> 8.0 has an option for this?[/color]

Here are the relevant options, from the Intel manual:

/Zc:forScope - enforce standard behavior for initializers of loops
/Za - Enforces strict conformance to the ANSI standard
for C
/Qms0 - Instructs the compiler to disable Microsoft
compatibility bugs.

Jonathan


Ali Cehreli
Guest
 
Posts: n/a
#6: Jul 22 '05

re: Intel C++ 8.0 : declaration hides declaration


"Chuck McDevitt" <Chuck_McDevitt@c-o-m-c-a-s-t.net> wrote in message news:<Ddccc.78943$JO3.41863@attbi_s04>...[color=blue]
> "Alex Vinokur" <alexvn@big.foot.com> wrote in message
> news:c4qu9m$2kb9ao$1@ID-79865.news.uni-berlin.de...[color=green]
> > ===========
> > Windows 2000
> > Intel C++ 8.0
> > ===========
> >
> > ------ foo.cpp ------
> > int main ()
> > {
> > for (int i = 0; i < 10; i++);
> > for (int i = 0; i < 10; i++);
> > return 0;
> > }
> > ---------------------
> >
> > --- Compilation ---
> >
> > $ icl foo.cpp
> >
> > Intel(R) C++ Compiler for 32-bit applications, Version 8.0 Build
> > 20031017Z Package ID: W_CC_P_8.0.040
> > Copyright (C) 1985-2003 Intel Corporation. All rights reserved.
> > 30 DAY EVALUATION LICENSE
> >
> > foo.cpp
> > icl: NOTE: The evaluation period for this product ends on 16-apr-2004 UTC.
> > foo.cpp(4): warning #1420: declaration in for-initializer hides a
> > declaration in the surrounding scope
> > the hidden declaration is at line 3
> > for (int i = 0; i < 10; i++);
> > ^
> >
> > foo.cpp(4): warning #1429: variable declaration hides declaration in
> > for-initializer
> > the hidden declaration is at line 3
> > for (int i = 0; i < 10; i++);
> > ^
> >
> > Microsoft (R) Incremental Linker Version 7.00.9466
> > Copyright (C) Microsoft Corporation. All rights reserved.
> >
> > -out:foo.exe
> > foo.obj
> >
> > -------------------
> >
> > Why does Intel C++ 8.0 produce the warnings?
> >
> > --[/color]
>
> It's a bug. Intel C++ 8.0 is handling the for loop scoping in the old way,
> where the variable declared in the for loop would still be in-scope after
> the loop exits.[/color]

I don't have that compiler but I don't think that's the case here. If
that was the case, then I would expect the compiler to emit an error
saying that 'i' was being redefined.

The fact that it's a warning about hiding a varible in the surrounding
scope, maybe the compiler gets the code as

for (int i = 0; i < 10; i++)
for (int i = 0; i < 10; i++);

But the original poster did show a semicolon after the first for loop.
(?)

Also, if the cryptic code at the original poster's output tells us
that the compiler is from 2003, I would be very much surprised if
Intel didn't get that behavior right already at that time.
[color=blue]
> Microsoft Visual C++ used to do this as well, and still does it if you don't
> tell it you want "Conforming" behaviour for for-loops. Perhaps Intel C++
> 8.0 has an option for this?
>
> Anyway, you can always add extra braces:
>
> int main ()
> {
> {for (int i = 0; i < 10; i++);}
> {for (int i = 0; i < 10; i++);}
> return 0;
> }
>
> That will make the warning go away.[/color]

Ali
Ali Cehreli
Guest
 
Posts: n/a
#7: Jul 22 '05

re: Intel C++ 8.0 : declaration hides declaration


"Chuck McDevitt" <Chuck_McDevitt@c-o-m-c-a-s-t.net> wrote in message news:<Ddccc.78943$JO3.41863@attbi_s04>...[color=blue]
> "Alex Vinokur" <alexvn@big.foot.com> wrote in message
> news:c4qu9m$2kb9ao$1@ID-79865.news.uni-berlin.de...[color=green]
> > ===========
> > Windows 2000
> > Intel C++ 8.0
> > ===========
> >
> > ------ foo.cpp ------
> > int main ()
> > {
> > for (int i = 0; i < 10; i++);
> > for (int i = 0; i < 10; i++);
> > return 0;
> > }
> > ---------------------
> >
> > --- Compilation ---
> >
> > $ icl foo.cpp
> >
> > Intel(R) C++ Compiler for 32-bit applications, Version 8.0 Build
> > 20031017Z Package ID: W_CC_P_8.0.040
> > Copyright (C) 1985-2003 Intel Corporation. All rights reserved.
> > 30 DAY EVALUATION LICENSE
> >
> > foo.cpp
> > icl: NOTE: The evaluation period for this product ends on 16-apr-2004 UTC.
> > foo.cpp(4): warning #1420: declaration in for-initializer hides a
> > declaration in the surrounding scope
> > the hidden declaration is at line 3
> > for (int i = 0; i < 10; i++);
> > ^
> >
> > foo.cpp(4): warning #1429: variable declaration hides declaration in
> > for-initializer
> > the hidden declaration is at line 3
> > for (int i = 0; i < 10; i++);
> > ^
> >
> > Microsoft (R) Incremental Linker Version 7.00.9466
> > Copyright (C) Microsoft Corporation. All rights reserved.
> >
> > -out:foo.exe
> > foo.obj
> >
> > -------------------
> >
> > Why does Intel C++ 8.0 produce the warnings?
> >
> > --[/color]
>
> It's a bug. Intel C++ 8.0 is handling the for loop scoping in the old way,
> where the variable declared in the for loop would still be in-scope after
> the loop exits.[/color]

I don't have that compiler but I don't think that's the case here. If
that was the case, then I would expect the compiler to emit an error
saying that 'i' was being redefined.

The fact that it's a warning about hiding a varible in the surrounding
scope, maybe the compiler gets the code as

for (int i = 0; i < 10; i++)
for (int i = 0; i < 10; i++);

But the original poster did show a semicolon after the first for loop.
(?)

Also, if the cryptic code at the original poster's output tells us
that the compiler is from 2003, I would be very much surprised if
Intel didn't get that behavior right already at that time.
[color=blue]
> Microsoft Visual C++ used to do this as well, and still does it if you don't
> tell it you want "Conforming" behaviour for for-loops. Perhaps Intel C++
> 8.0 has an option for this?
>
> Anyway, you can always add extra braces:
>
> int main ()
> {
> {for (int i = 0; i < 10; i++);}
> {for (int i = 0; i < 10; i++);}
> return 0;
> }
>
> That will make the warning go away.[/color]

Ali
Jonathan Turkanis
Guest
 
Posts: n/a
#8: Jul 22 '05

re: Intel C++ 8.0 : declaration hides declaration



"Ali Cehreli" <acehreli@yahoo.com> wrote in message
news:f0070508.0404051315.7c18c916@posting.google.c om...[color=blue]
> "Chuck McDevitt" <Chuck_McDevitt@c-o-m-c-a-s-t.net> wrote in message[/color]
news:<Ddccc.78943$JO3.41863@attbi_s04>...

<snip>
[color=blue][color=green]
> >
> > It's a bug. Intel C++ 8.0 is handling the for loop scoping in the[/color][/color]
old way,[color=blue][color=green]
> > where the variable declared in the for loop would still be[/color][/color]
in-scope after[color=blue][color=green]
> > the loop exits.[/color]
>
> I don't have that compiler but I don't think that's the case here.[/color]
If[color=blue]
> that was the case, then I would expect the compiler to emit an error
> saying that 'i' was being redefined.
>[/color]

<snip>
[color=blue]
> Also, if the cryptic code at the original poster's output tells us
> that the compiler is from 2003, I would be very much surprised if
> Intel didn't get that behavior right already at that time.[/color]

The code compiles on Intel 8.0 for windows with the command-line
option /Zc:forScope, but not without it.

Intel for Windows can be highly conformant if you use the right
options, but by default it has a lot of microsoft compatibility stuff.
Of course microsoft has gotten much better, too, but you still need to
explicitly disable 'microsoft extensions' if you want to approach ISO
conformance.

Jonathan


Jonathan Turkanis
Guest
 
Posts: n/a
#9: Jul 22 '05

re: Intel C++ 8.0 : declaration hides declaration



"Ali Cehreli" <acehreli@yahoo.com> wrote in message
news:f0070508.0404051315.7c18c916@posting.google.c om...[color=blue]
> "Chuck McDevitt" <Chuck_McDevitt@c-o-m-c-a-s-t.net> wrote in message[/color]
news:<Ddccc.78943$JO3.41863@attbi_s04>...

<snip>
[color=blue][color=green]
> >
> > It's a bug. Intel C++ 8.0 is handling the for loop scoping in the[/color][/color]
old way,[color=blue][color=green]
> > where the variable declared in the for loop would still be[/color][/color]
in-scope after[color=blue][color=green]
> > the loop exits.[/color]
>
> I don't have that compiler but I don't think that's the case here.[/color]
If[color=blue]
> that was the case, then I would expect the compiler to emit an error
> saying that 'i' was being redefined.
>[/color]

<snip>
[color=blue]
> Also, if the cryptic code at the original poster's output tells us
> that the compiler is from 2003, I would be very much surprised if
> Intel didn't get that behavior right already at that time.[/color]

The code compiles on Intel 8.0 for windows with the command-line
option /Zc:forScope, but not without it.

Intel for Windows can be highly conformant if you use the right
options, but by default it has a lot of microsoft compatibility stuff.
Of course microsoft has gotten much better, too, but you still need to
explicitly disable 'microsoft extensions' if you want to approach ISO
conformance.

Jonathan


Closed Thread