https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65498

            Bug ID: 65498
           Summary: ICE in cxx_eval_call_expression when using __func__
                    inside dependent context
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ldionne.2 at gmail dot com

The following code triggers an ICE on GCC trunk:
------------------------------------------------------------------------------
    #include <type_traits>

    struct T;

    template <typename, typename = void>
    struct F { };

    template <typename X>
    struct F<X, std::enable_if_t<std::is_same<X, T>{}()>> {
        template <typename MakeDependent>
        F(MakeDependent) {
            auto ICE_HERE = __func__;
            (void)ICE_HERE; // avoid -Wunused-variable
        }
    };

    int main() {
        F<T>{1};
    }
------------------------------------------------------------------------------


Example run:
------------------------------------------------------------------------------
› ~/code/gcc5/bin/g++ -std=c++1y ~/code/hana/test/worksheet.cpp
/Users/ldionne/code/hana/test/worksheet.cpp: In substitution of ‘template<bool
_Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool
_Cond = std::is_same<T, T>{}(); _Tp = void]’:
/Users/ldionne/code/hana/test/worksheet.cpp:1411:25:   required from here
/Users/ldionne/code/hana/test/worksheet.cpp:1408:50:   in constexpr expansion
of ‘((std::integral_constant<bool, true>*)(& std::is_same<T,
T>()))->std::integral_constant<_Tp, __v>::operator()<bool, true>()’
/Users/ldionne/code/hana/test/worksheet.cpp:1411:25: internal compiler error:
in cxx_eval_call_expression, at cp/constexpr.c:1358
         auto ICE_HERE = __func__;
                         ^

/Users/ldionne/code/hana/test/worksheet.cpp:1411:25: internal compiler error:
Abort trap: 6
g++: internal compiler error: Abort trap: 6 (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
------------------------------------------------------------------------------

Note that using 

    std::is_same<X, T>::value

instead of 

    std::is_same<X, T>{}()

seems to fix the issue.


Regards,
Louis Dionne

Reply via email to