Strange warning in C++11 range based for loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello!
I have some class, that allows to iterate through numeric range.
For example code:

> for (int i: range(N)) {
>    cout << i << endl;
> }

works fine. But if I try repeatedly do some action:

> for (int i: range(N)) {
>    doSomething();
> }

compiler gives me warning:

> warning: unused variable `i' [-Wunused-variable]

But at same time classic for-loop:

> for (int i =3D 0; i < N; ++i) {
>     doSomething();
> }

compiles without warnings.
My compiler's version is "g++-4.6 (GCC) 4.6.1", compiler flags
"--std=c++0x -Wall"
I'm wondering, is it planned behavior or bug?
Thank you for help.
--
Pavel Sergeev



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux