public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/68144] New: operator~ in trailing return type leads to spurrious error
@ 2015-10-29 13:59 joel.falcou at lri dot fr
0 siblings, 0 replies; only message in thread
From: joel.falcou at lri dot fr @ 2015-10-29 13:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68144
Bug ID: 68144
Summary: operator~ in trailing return type leads to spurrious
error
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: joel.falcou at lri dot fr
Target Milestone: ---
THe following code :
#include <iostream>
struct bar
{
template<typename T>
auto operator()(T const& a) const -> decltype(~a) { return ~a; }
};
int main()
{
// works
std::cout << ~1 << std::endl;
// doesnt work
bar z;
std::cout << z(1) << std::endl;
}
Fails on g++ 5.2.0 with the following error:
main.cpp: In substitution of 'template<class T> decltype (~ a)
bar::operator()(const T&) const [with T = int]':
main.cpp:15:19: required from here
main.cpp:5:29: error: 'a' was not declared in this scope
Changing -> decltype(~a) to -> decltype(~(a)) fixes this incorrect behavior.
Clang++ currently compiles this code correctly.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-10-29 13:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-29 13:59 [Bug c++/68144] New: operator~ in trailing return type leads to spurrious error joel.falcou at lri dot fr
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).