[llvm-bugs] [Bug 38206] New: use of local variable with automatic storage from containing function

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 17 19:44:35 PDT 2018


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

            Bug ID: 38206
           Summary: use of local variable with automatic storage from
                    containing function
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: zhonghao at pku.org.cn
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

The code is as follow:

template <int>
int f(void)
{
 int i;
 struct f1
 {
 int f(void){return i;}
 };
}

Clang++ accepts the code, but g++ rejects it:


code0.cpp: In member function 'int f()::f1::f()':
code0.cpp:7:21: error: use of local variable with automatic storage from
containing function
  int f(void){return i;}
                     ^
code0.cpp:4:6: note: 'int i' declared here
  int i;
      ^
code0.cpp: In function 'int f()':
code0.cpp:9:1: warning: no return statement in function returning non-void
[-Wreturn-type]
 }
 ^

-- 
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/20180718/0a68cd01/attachment.html>


More information about the llvm-bugs mailing list