This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/57346] g++ prematurely rejects references to local variables that are not odr-uses from local classes inside templates
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 22 Jul 2016 17:41:44 +0000
- Subject: [Bug c++/57346] g++ prematurely rejects references to local variables that are not odr-uses from local classes inside templates
- Auto-submitted: auto-generated
- References: <bug-57346-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57346
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-07-22
CC| |msebor at gcc dot gnu.org
Ever confirmed|0 |1
Known to fail| |4.5.3, 4.8.3, 4.9.3, 5.3.0,
| |6.1.0, 7.0
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. Both Clang 3.8 and EDG eccp 4.11 successfully compile the code.
GCC apparently never has.
$ cat y.C && /build/gcc-trunk-git/gcc/xgcc -B /build/gcc-trunk-git/gcc -S -Wall
-Wextra -Wpedantic y.C
template<typename T> int f() {
T n = 0;
struct X { int get() { return n; } } x;
return x.get();
}
y.C: In member function ‘int f()::X::get()’:
y.C:3:35: error: use of local variable with automatic storage from containing
function
struct X { int get() { return n; } } x;
^
y.C:2:7: note: ‘T n’ declared here
T n = 0;
^