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: unassignedclangb...@nondot.org
          Reporter: zhong...@pku.org.cn
                CC: dgre...@apple.com, llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to