[cfe-dev] Is this valid code ?

Richard Smith richard at metafoo.co.uk
Sat Jul 11 02:47:58 PDT 2015


On 11 Jul 2015 1:26 am, "Manasij Mukherjee" <manasij7479 at gmail.com> wrote:
>
> Hi
> Clang and MSVC accepts the following code.
> But I get
> error: use of 'x' before deduction of 'auto'
> with GCC (5.1, C++14 enabled)
>
> int main() {
>   int x[] = {1,2,3,4,5};
>   for (auto x : x) {
>   }
> }

It's a gcc bug, they get the scope of range-for variables wrong.

> Thanks,
> Manasij Mukherjee
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150711/c7ec9228/attachment.html>


More information about the cfe-dev mailing list