This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/60463] New: Lambda function can call a non-const member function with const this
- From: "topi.musto at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 07 Mar 2014 23:32:27 +0000
- Subject: [Bug c++/60463] New: Lambda function can call a non-const member function with const this
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60463
Bug ID: 60463
Summary: Lambda function can call a non-const member function
with const this
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: topi.musto at gmail dot com
The following C++11 translation unit shouldn't compile, because g is non-const
and f is const:
struct A
{
void g()
{
}
void f() const
{
[this]() { g(); }();
}
};
Yet it compiles with g++ -std=c++11 -Wall -Wextra
Tested with
g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1, and
g++ (GCC) 4.9.0 20140307 (experimental)
Note that calling the function with this->g(); gives the expected error
message:
"error: passing âconst Aâ as âthisâ argument of âvoid A::g()â discards
qualifiers [-fpermissive]"