[llvm-bugs] [Bug 35957] New: When declaring variable with __auto_type, name should not be in scope until after initializer

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 15 23:48:44 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=35957

            Bug ID: 35957
           Summary: When declaring variable with __auto_type, name should
                    not be in scope until after initializer
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: oliver.kleinke at c-01a.de
                CC: llvm-bugs at lists.llvm.org

Created attachment 19679
  --> https://bugs.llvm.org/attachment.cgi?id=19679&action=edit
example program code

When declaring a variable with __auto_type and initializing it with a variable
in an outer scope, having the same name, clang fails with

"error: variable 'var' declared with deduced type '__auto_type' cannot appear
in its own initializer"

The GCC docs (https://gcc.gnu.org/onlinedocs/gcc/Typeof.html, at bottom) state
that "[..]the name of the variable is not in scope until after the
initializer."

Note that GCC behaviour is similar to a variable declaration with a standard
type-specifier. I attach a small example that demonstrates both cases.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180116/1fc51815/attachment-0001.html>


More information about the llvm-bugs mailing list