https://bugs.llvm.org/show_bug.cgi?id=43335

            Bug ID: 43335
           Summary: Compiler recurses infinitely and exausts stack
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

This code exhausts the stack:


struct Foo {
    template <class... T>
    Foo(T... a, decltype(Foo(a...))* = nullptr) {}
} foo(1);


https://godbolt.org/z/ahHavv

I wasn't sure if I should even report this because the code is obviously
broken. I decided to do so because:

1 - Maybe it is worth looking into as it could be indication of architectural
problem
2 - The error message could be better. I guess it should be possible to detect
this scenario and avoid infinite recursion.
3 - With this slight variation, clang give a more sane error message:

struct Foo {
    template <class... T>
    Foo(T... a, decltype(Foo(1))* = nullptr) {}
} foo(1);

https://godbolt.org/z/eo8zAX


Fun fact: Both GCC and MSVC do not like this code.
https://godbolt.org/z/olrorn
https://godbolt.org/z/BeDsBY

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to