From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8489 invoked by alias); 13 Feb 2012 00:34:20 -0000 Received: (qmail 8046 invoked by uid 22791); 13 Feb 2012 00:34:19 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Feb 2012 00:34:06 +0000 From: "solodon at mail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52224] New: [C++0x] Generic operator gets pulled into compile-time expression Date: Mon, 13 Feb 2012 00:34:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: solodon at mail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-02/txt/msg01229.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52224 Bug #: 52224 Summary: [C++0x] Generic operator gets pulled into compile-time expression Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: solodon@mail.com Created attachment 26644 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26644 Code reproducing bug Hi, I have a piece of code that crashes gcc 4.5.2 and runs out of template instantiation depth in 4.6.1, while I believe it should be well formed. The command line I used for both compilers is: g++ -std=c++0x gcc_bug_mini.cpp #include #include // I can have multiple my_... classes, template struct my_class {}; // Which is why for convenience I introduce this predicate template struct is_mine { enum { value = false }; }; template struct is_mine> { enum { value = true }; }; // Note the use of || here, use of + would make things compile template struct either_is_mine { enum { value = is_mine::value || is_mine::value }; }; // Generic || that should only be used when one of arguments is my_... template inline auto operator||(E1&& e1, E2&& e2) throw() -> typename std::enable_if::value, int>::type; template auto test(E1&& e1, E2&& e2) -> typename std::enable_if::value, int>::type; int main() { test(3,12); } The problem is in || in the definition of either_is_mine: for some reason the generic operator enabled only when one of the arguments is from my_... set is considered as a possible overload (note that there is no constexpr on generic operator, just inline). GCC in both cases is running under MinGW on Windows 7 laptop. Thanks, Yuriy