https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65598
Bug ID: 65598 Summary: Misleading error message for out-of-class definition of explicit conversion operator Product: gcc Version: 4.9.1 Status: UNCONFIRMED Severity: trivial Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: arvo at me dot com Created attachment 35160 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35160&action=edit Preprocessed source System report: OS: GNU/Linux x86_64 Distribution: openSUSE 13.1 Package info: Informationen für Paket gcc49-c++: ---------------------------------- Repository: @System Name: gcc49-c++ Version: 4.9.1+r213409-44.1 Arch: x86_64 Anbieter: obs://build.opensuse.org/devel:gcc Installiert: Ja Status: aktuell Installierte Größe: 17,3 MiB Zusammenfassung: The GNU C++ Compiler Beschreibung: This package contains the GNU compiler for C++. Test program (C++11): struct ExplicitTest { explicit operator bool() const; }; explicit ExplicitTest::operator bool() const { return true; } The program is ill-formed because explicit is only allowed inside a class definition, as per §7.1.2/6 Function Specifiers [N3376]. However, the error message is misleading and seems not to have been updated for C++11, where explicit conversion operators were introduced: $ g++-4.9 -c -std=c++11 explicit_operator_bool.cxx explicit_operator_bool.cxx:6:40: error: only declarations of constructors can be ‘explicit’ explicit ExplicitTest::operator bool() const ^ (Also it would probably be better to place the caret underneath "explicit".)