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.