public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51927] New: [C++0x] Cannot access non-static members in initializer
@ 2012-01-21 3:12 gccearlyadopter@trash-mail.com
2012-05-30 7:58 ` [Bug c++/51927] " gccearlyadopter@trash-mail.com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: gccearlyadopter@trash-mail.com @ 2012-01-21 3:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51927
Bug #: 51927
Summary: [C++0x] Cannot access non-static members in
initializer
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: gccearlyadopter@trash-mail.com
GCC47 doesn't allow to access non-static members in non-static member
initialization. The following program fails to compile with the error "invalid
use of non-static data member 'testee::l1'".
#include <iostream>
#include <functional>
using std::cout;
using std::endl;
struct testee
{
std::function<void()> l1 = []()
{
cout << "world" << endl;
};
std::function<void()> l2 = [=]()
{
cout << "hello " << endl;
l1();
};
};
int main()
{
testee t;
t.l2();
}
Taking the address of l1 in the lambda expression used to initialize l2 is also
refused by GCC.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/51927] [C++0x] Cannot access non-static members in initializer
2012-01-21 3:12 [Bug c++/51927] New: [C++0x] Cannot access non-static members in initializer gccearlyadopter@trash-mail.com
@ 2012-05-30 7:58 ` gccearlyadopter@trash-mail.com
2012-05-30 8:52 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: gccearlyadopter@trash-mail.com @ 2012-05-30 7:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51927
--- Comment #1 from gccearlyadopter@trash-mail.com 2012-05-30 07:48:35 UTC ---
This Bug still exists in the latest GCC 4.7 release.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/51927] [C++0x] Cannot access non-static members in initializer
2012-01-21 3:12 [Bug c++/51927] New: [C++0x] Cannot access non-static members in initializer gccearlyadopter@trash-mail.com
2012-05-30 7:58 ` [Bug c++/51927] " gccearlyadopter@trash-mail.com
@ 2012-05-30 8:52 ` redi at gcc dot gnu.org
2012-05-30 12:43 ` gccearlyadopter@trash-mail.com
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2012-05-30 8:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51927
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-05-30
Ever Confirmed|0 |1
Known to fail| |4.7.1, 4.8.0
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-05-30 08:38:03 UTC ---
4.7.0 *is* the latest GCC release :)
Anyway, confirmed, the example looks valid to me.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/51927] [C++0x] Cannot access non-static members in initializer
2012-01-21 3:12 [Bug c++/51927] New: [C++0x] Cannot access non-static members in initializer gccearlyadopter@trash-mail.com
2012-05-30 7:58 ` [Bug c++/51927] " gccearlyadopter@trash-mail.com
2012-05-30 8:52 ` redi at gcc dot gnu.org
@ 2012-05-30 12:43 ` gccearlyadopter@trash-mail.com
2012-12-05 17:29 ` js at lastlog dot de
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: gccearlyadopter@trash-mail.com @ 2012-05-30 12:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51927
--- Comment #3 from gccearlyadopter@trash-mail.com 2012-05-30 12:34:12 UTC ---
My local GCC says "4.7.0_3". :)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/51927] [C++0x] Cannot access non-static members in initializer
2012-01-21 3:12 [Bug c++/51927] New: [C++0x] Cannot access non-static members in initializer gccearlyadopter@trash-mail.com
` (2 preceding siblings ...)
2012-05-30 12:43 ` gccearlyadopter@trash-mail.com
@ 2012-12-05 17:29 ` js at lastlog dot de
2013-05-04 12:20 ` paolo.carlini at oracle dot com
2013-05-04 12:33 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: js at lastlog dot de @ 2012-12-05 17:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51927
js at lastlog dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |js at lastlog dot de
--- Comment #4 from js at lastlog dot de 2012-12-05 17:29:35 UTC ---
still seems to be broken in 4.7.2 :-P
but is known to be working with llvm 3.2
# make
simple.cpp: In lambda function:
simple.cpp:11:5: error: invalid use of non-static data member ‘testee::l1’
simple.cpp:15:9: error: from this location
make[2]: *** [CMakeFiles/simple.dir/simple.cpp.o] Error 1
make[1]: *** [CMakeFiles/simple.dir/all] Error 2
make: *** [all] Error 2
*** Failed ***
# g++ --version
g++ (Ubuntu/Linaro 4.7.2-11precise2) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/51927] [C++0x] Cannot access non-static members in initializer
2012-01-21 3:12 [Bug c++/51927] New: [C++0x] Cannot access non-static members in initializer gccearlyadopter@trash-mail.com
` (3 preceding siblings ...)
2012-12-05 17:29 ` js at lastlog dot de
@ 2013-05-04 12:20 ` paolo.carlini at oracle dot com
2013-05-04 12:33 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-04 12:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51927
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.8.0, 4.9.0
Known to fail|4.8.0 |
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-05-04 12:20:56 UTC ---
This is fixed. I'm adding the testcase and closing the report.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/51927] [C++0x] Cannot access non-static members in initializer
2012-01-21 3:12 [Bug c++/51927] New: [C++0x] Cannot access non-static members in initializer gccearlyadopter@trash-mail.com
` (4 preceding siblings ...)
2013-05-04 12:20 ` paolo.carlini at oracle dot com
@ 2013-05-04 12:33 ` paolo.carlini at oracle dot com
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-04 12:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51927
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Blocks| |54367
Resolution| |FIXED
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-05-04 12:33:13 UTC ---
Done.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-05-04 12:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-21 3:12 [Bug c++/51927] New: [C++0x] Cannot access non-static members in initializer gccearlyadopter@trash-mail.com
2012-05-30 7:58 ` [Bug c++/51927] " gccearlyadopter@trash-mail.com
2012-05-30 8:52 ` redi at gcc dot gnu.org
2012-05-30 12:43 ` gccearlyadopter@trash-mail.com
2012-12-05 17:29 ` js at lastlog dot de
2013-05-04 12:20 ` paolo.carlini at oracle dot com
2013-05-04 12:33 ` paolo.carlini at oracle dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).