http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57743
Bug ID: 57743 Summary: Code accepted by other recent compilers, but not by g++ - possibly failure to activate ADL Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: unmobile at gmail dot com Created attachment 30401 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30401&action=edit Reduced test case $ g++ --version g++ (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3 $ g++ -c puptest0.C puptest0.C: In member function ‘void SDAG::Closure::packClosure(PUP::er&)’: puptest0.C:27: error: no match for ‘operator|’ in ‘p | ((SDAG::Closure*)this)->SDAG::Closure::continuations’ Tested with 4.8 and snapshots of 4.9, and all they add to that output (appears in at least 4.3, 4.4, and 4.6) is column numbering and caret marking of that exact spot. (g++-mp-4.9 --version gives "g++-mp-4.9 (MacPorts gcc49 4.9-20130623_0) 4.9.0 20130623 (experimental)") Reduced test case attached. Defining either of the tested macros lets the code compile. Commenting either of the friend declarations also lets the code compile. Moving the friend declarations out of the structure definition (and making them non-friend) lets the code compile. The code in question is accepted by clang of various versions including 3.3, IBM XL C++ 12.01, Intel C++ versions 12.1.5.339 and 13.1 (but rejected by 11.1 with a similar error), and PGI C++ from 11.0 through 13.3. MSVC++ v16 rejects it (not sure what year that's from). Cray's compiler v8 also rejects it, again similarly. The rejections from other compilers, and g++'s own when I vary conditions (cf http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57739) might be enlightening. Intel 11.1 and Cray v8 provide no additional information, while MS VC++ is similar to the related case output: puptest0.C(27) : error C2679: binary '|' : no operator found which takes a right-hand operand of type 'A' (or there is no acceptable conversion) puptest0.C(24): could be 'void SDAG::operator |(PUP::er &,SDAG::Closure &)' puptest0.C(25): or 'void SDAG::operator |(PUP::er &,SDAG::Closure *&)' while trying to match the argument list '(PUP::er, A)' Going by the fact that where versions differ, the later version accepts, I believe that there is a bug in g++ rejecting this code. It seems like any little tweak lets the compiler apply argument dependent lookup and resolve the operator successfully, but I don't know why it isn't already.