https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66157

            Bug ID: 66157
           Summary: bits/random.tcc compiler error when using
                    -fno-for-scope
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luca.stoppa at bbh dot com
  Target Milestone: ---

Created attachment 35545
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35545&action=edit
That example won't compile

Compiling a minimal example (empty main) that includes <algorithm> will result
into a compilation error.

g++ -std=c++14 -fno-for-scope m.cpp

/opt/rh/devtoolset-3/root/usr/include/c++/4.9.1/bits/random.tcc: In member
function âvoid std::seed_seq::generate(_RandomAccessIterator,
_RandomAccessIterator)â:
/opt/rh/devtoolset-3/root/usr/include/c++/4.9.1/bits/random.tcc:3444:19: error:
redeclaration of âstd::size_t __kâ
       for (size_t __k = __m; __k < __m + __n; ++__k)
                   ^
/opt/rh/devtoolset-3/root/usr/include/c++/4.9.1/bits/random.tcc:3422:19: note:
âstd::size_t __kâ previously declared here
       for (size_t __k = 0; __k < __m; ++__k)

I have checked the newest libstdc++ source code and the but is still there.
I would like to know whether
- "-fno-for-scope" is still a supported flag for c++11/14/1y, in that case I
believe I hit an implementation error. In case you decide this is really an
error the fix is really easy: __k should be changed to __k1 in the first loop,
__k2 in the second loop, and so on.
- if it is not supported, I think the gcc documentation should be updated.

Testcases:
g++ -std=c++11 -fno-for-scope m.cpp won't compile
g++ -std=c++14 -fno-for-scope m.cpp won't compile
g++ -std=c++1y -fno-for-scope m.cpp won't compile

when removing -fno-for-scope everything is fine.

Thanks,
Luca

Reply via email to