473,386 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Intel C++ 8.0 : declaration hides declaration

===========
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:al****@connect.to
http://mathforum.org/library/view/10978.html

Jul 22 '05 #1
8 3114

"Alex Vinokur" <al****@big.foot.com> wrote in message
news:c4*************@ID-79865.news.uni-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.


Jul 22 '05 #2

"Alex Vinokur" <al****@big.foot.com> wrote in message
news:c4*************@ID-79865.news.uni-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.


Jul 22 '05 #3

"Chuck McDevitt" <Ch************@c-o-m-c-a-s-t.net> wrote in message
news:Ddccc.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
Jul 22 '05 #4

"Chuck McDevitt" <Ch************@c-o-m-c-a-s-t.net> wrote in message
news:Ddccc.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
Jul 22 '05 #5
"Chuck McDevitt" <Ch************@c-o-m-c-a-s-t.net> wrote in message news:<Ddccc.78943$JO3.41863@attbi_s04>...
"Alex Vinokur" <al****@big.foot.com> wrote in message
news:c4*************@ID-79865.news.uni-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
Jul 22 '05 #6
"Chuck McDevitt" <Ch************@c-o-m-c-a-s-t.net> wrote in message news:<Ddccc.78943$JO3.41863@attbi_s04>...
"Alex Vinokur" <al****@big.foot.com> wrote in message
news:c4*************@ID-79865.news.uni-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
Jul 22 '05 #7

"Ali Cehreli" <ac******@yahoo.com> wrote in message
news:f0**************************@posting.google.c om...
"Chuck McDevitt" <Ch************@c-o-m-c-a-s-t.net> 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
Jul 22 '05 #8

"Ali Cehreli" <ac******@yahoo.com> wrote in message
news:f0**************************@posting.google.c om...
"Chuck McDevitt" <Ch************@c-o-m-c-a-s-t.net> 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
Jul 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Alex Vinokur | last post by:
=========== Windows 2000 Intel C++ 8.0 =========== ------ foo.cpp ------ int main () { for (int i = 0; i < 10; i++); for (int i = 0; i < 10; i++);
4
by: Marcin Kalicinski | last post by:
Hi, Should the below code compile according to C++ standard? namespace N { struct S{ }; } void S() { } using N::S; It seems that various compilers behave differently with it. I found the...
2
by: Ryan Mitchley | last post by:
Hi all I have code for an object factory, heavily based on an article by Jim Hyslop (although I've made minor modifications). The factory was working fine using g++, but since switching to the...
4
by: Christian Christmann | last post by:
Hi, I'm reading "C++ Coding Standards" by Herb Sutter. On page 67 there's an example which I don't understand: --------------------------------- class Base{// ... virtual void Foo(int);...
3
by: gugdias | last post by:
I'm coding a simple matrix class, which is resulting in the following error when compiling with g++ 3.4.2 (mingw-special): * declaration of `operator/' as non-function * expected `;' before '<'...
5
by: Subrahmanyam Arya | last post by:
Hi Folks , I am trying to solve the problem of reading the numbers correctly from a serial line into an intel pentium processor machine . I am reading 1 byte and 2byte data both positive...
3
by: Wayne Brantley | last post by:
VS2005 RTM Create a web user control to use as a base class for other web user controls. Now, create a new web user control, change the class it inherits from to your base class and compile....
7
by: Paminu | last post by:
On a gentoo linux system i don't get any warnings when I comlpile this code: #include <stdio.h> typedef struct test { void *content; struct test_ *bob; } test_;
4
by: the_init | last post by:
Hi friends, Can you please explain me why the following code prints 10, instead of 20 - Here I am little confused with the static and global declaration of i in the same program. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.