[llvm-bugs] [Bug 43335] New: Compiler recurses infinitely and exausts stack

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 16 17:16:11 PDT 2019


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: unassignedclangbugs at nondot.org
          Reporter: brenorg at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190917/152e0546/attachment.html>


More information about the llvm-bugs mailing list