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++/79865] New: Crash when calling member function with template parameter from generic lambda


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

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

Created attachment 40882
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40882&action=edit
GCC Version

Inputting this code makes GCC crash on the call of `crashIt`:

    #include <tuple>

    struct Subject {
        using Types = std::tuple<int, double>;
    };

    struct Test {
        template<typename T>
        void test() {
            test<T>(std::make_index_sequence<std::tuple_size<typename
T::Types>::value>{});
        }

        template<typename T, std::size_t... S>
        void test(std::index_sequence<S...>) {
            int unpack[] = {(static_cast<void>([&](auto i){
                using Type = std::tuple_element_t<i, typename T::Types>;

                crashIt<Type>(); // Here's the crash!

            }(std::integral_constant<std::size_t, S>{})), 0)..., 0};

            (void)unpack;
        }

        template<typename>
        void crashIt() {}
    };

    int main(){
        Test{}.test<Subject>();
    }

Not using a lambda in the expansion of `S` make the code compile.
This code compile fine under Clang 3.9.1.

The complete GCC version is in the attachement.

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