Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Intel C++ 8.0 : declaration hides declaration

Reply
Thread Tools

Intel C++ 8.0 : declaration hides declaration

 
 
Alex Vinokur
Guest
Posts: n/a
 
      04-05-2004
===========
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
(E-Mail Removed)
http://mathforum.org/library/view/10978.html





 
Reply With Quote
 
 
 
 
Chuck McDevitt
Guest
Posts: n/a
 
      04-05-2004

"Alex Vinokur" <(E-Mail Removed)> wrote in message
news:c4qu9m$2kb9ao$(E-Mail Removed)-berlin.de...
> ===========
> 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?
>
> --


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.




 
Reply With Quote
 
 
 
 
Jonathan Turkanis
Guest
Posts: n/a
 
      04-05-2004

"Chuck McDevitt" <(E-Mail Removed)> wrote in message
newsdccc.78943$JO3.41863@attbi_s04...
>



>
> 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?


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


 
Reply With Quote
 
Ali Cehreli
Guest
Posts: n/a
 
      04-05-2004
"Chuck McDevitt" <(E-Mail Removed)> wrote in message news:<Ddccc.78943$JO3.41863@attbi_s04>...
> "Alex Vinokur" <(E-Mail Removed)> wrote in message
> news:c4qu9m$2kb9ao$(E-Mail Removed)-berlin.de...
> > ===========
> > 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?
> >
> > --

>
> 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.


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.

> 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.


Ali
 
Reply With Quote
 
Jonathan Turkanis
Guest
Posts: n/a
 
      04-05-2004

"Ali Cehreli" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> "Chuck McDevitt" <(E-Mail Removed)> wrote in message

news:<Ddccc.78943$JO3.41863@attbi_s04>...

<snip>

> >
> > 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.

>
> 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.
>


<snip>

> 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.


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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Declaration hides port port_name / Port port_name hidden by declaration in architecture Merciadri Luca VHDL 2 11-02-2010 08:23 PM
hides inherited member ApplicationInstance Wayne Brantley ASP .Net 3 12-19-2005 02:06 AM
JAXB: Nested Type hides an Enclosing Type. chicagoandy@hotmail.com Java 6 03-02-2005 04:57 PM
listbox hides the drop down menu Reb ASP .Net 3 11-27-2003 10:38 AM
Approximately needed score (I know MS hides the score...) for passing 70-305??? Daniel Walzenbach MCSD 2 11-09-2003 10:04 PM



Advertisments