From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28273 invoked by alias); 29 Mar 2013 13:44:58 -0000 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 Received: (qmail 28131 invoked by uid 48); 29 Mar 2013 13:44:47 -0000 From: "daniel.kruegler at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/56782] New: [C++11] Regression with empty pack expansions Date: Fri, 29 Mar 2013 13:44: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: daniel.kruegler at googlemail 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 X-SW-Source: 2013-03/txt/msg02198.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56782 Bug #: 56782 Summary: [C++11] Regression with empty pack expansions Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: daniel.kruegler@googlemail.com As of gcc 4.8.0 the following code is now rejected when compiled with flags -std=c++11 -Wall -W -pedantic //--------------------------- template T&& declval(); struct is_convertible_impl { template static void sink(T); template(declval()))> static auto test(int) -> char; template static auto test(...) -> char(&)[2]; }; template struct is_convertible : is_convertible_impl { static const bool value = sizeof(test(0)) == 1; }; template struct enable_if {}; template struct enable_if { typedef T type; }; template struct conditional { typedef If type; }; template struct conditional { typedef Else type; }; template struct and_; template<> struct and_<> { static const bool value = true; }; template struct and_

: P { }; template struct and_ : conditional::type { }; template struct Tuple { template... >::value, int>::type > Tuple(U&&...){} }; static_assert(is_convertible, Tuple>::value, "Ouch"); // OK static_assert(is_convertible, Tuple<>>::value, "Ouch"); // Error //--------------------------- The diagnostics being: " Compilation finished with errors: source.cpp:18:48: error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum) substituting 'template static char (& is_convertible_impl::test(...))[2] [with = Tuple<>; = Tuple<>]' static const bool value = sizeof(test(0)) == 1; ^ source.cpp:55:5: recursively required from 'const bool is_convertible, Tuple<> >::value' source.cpp:55:5: required from 'const bool is_convertible, Tuple<> >::value' source.cpp:64:49: required from here source.cpp:18:48: error: no matching function for call to 'is_convertible, Tuple<> >::test(int)' source.cpp:18:48: note: candidates are: source.cpp:9:15: note: template static char is_convertible_impl::test(int) static auto test(int) -> char; ^ source.cpp:9:15: note: template argument deduction/substitution failed: source.cpp:12:15: note: template static char (& is_convertible_impl::test(...))[2] static auto test(...) -> char(&)[2]; ^ source.cpp:12:15: note: substitution of deduced template arguments resulted in errors seen above source.cpp:64:1: error: non-constant condition for static assertion static_assert(is_convertible, Tuple<>>::value, "Ouch"); // Error ^ source.cpp:64:1: error: the value of 'is_convertible, Tuple<> >::value' is not usable in a constant expression source.cpp:18:21: note: 'is_convertible, Tuple<> >::value' was not initialized with a constant expression static const bool value = sizeof(test(0)) == 1; ^ " The code is accepted with gcc 4.7.2 and with Clang 3.2. It seems that for empty expansions the compiler erroneously does enter into the actually empty expansion: is_convertible...