This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/81236] New: Crash when calling a template member function from generic lambda


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

            Bug ID: 81236
           Summary: Crash when calling a template member function from
                    generic lambda
           Product: gcc
           Version: 7.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gufideg at gmail dot com
  Target Milestone: ---

This causes current G++ (7.1.1) to crash:

    #include <tuple>

    template <typename T, T... S, typename F>
    constexpr void for_sequence(std::integer_sequence<T, S...>, F&& f) {
        using unpack_t = int[];
        (void)unpack_t{(static_cast<void>(f(std::integral_constant<T, S>{})),
0)..., 0};
    }

    template<typename Tup>
    struct MyType {
        void crash() {
           
for_sequence(std::make_index_sequence<std::tuple_size<Tup>::value>{}, [&](auto
i){
                make_crash<i>(); // Line (1)
            });
        }

        template<int i>
        void make_crash() {}
    };

    int main() {
        MyType<std::tuple<int, double, double, const char*>> test;

        test.crash();
    }

Commenting line marked as `(1)` makes the code compile.

This code is valid and compiles under clang (3.8.0)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]