[llvm-bugs] [Bug 42372] New: Segfault when parsing use of static data member template with deduced type dependent on class template template parameter

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 24 09:06:13 PDT 2019


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

            Bug ID: 42372
           Summary: Segfault when parsing use of static data member
                    template with deduced type dependent on class template
                    template parameter
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eracpp at eml.cc
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

The following example (https://gcc.godbolt.org/z/lrNU6I):

template <typename> int C = 0;

template <template <typename> typename T>
struct S
{
    template <typename U>
    static auto const X = C<T<U>>;

    int x = X<void>;
};

Produces a stack dump (omitted program arguments flags due to verbosity; see
the Compiler Explorer link above for full message):

Stack dump:
0.      Program arguments: ...
1.      <eof> parser at end of file
2.      <source>:4:1: parsing struct/union/class body 'S'
#0 0x000055eb13de3c4a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/opt/compiler-explorer/clang-trunk-20190624/bin/clang-9+0x2754c4a)
#1 0x000055eb13de1a14 llvm::sys::RunSignalHandlers()
(/opt/compiler-explorer/clang-trunk-20190624/bin/clang-9+0x2752a14)
#2 0x000055eb13de1b52 SignalHandler(int)
(/opt/compiler-explorer/clang-trunk-20190624/bin/clang-9+0x2752b52)
#3 0x00007ff38b971890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
clang-9: error: unable to execute command: Segmentation fault (core dumped)
clang-9: error: clang frontend command failed due to signal (use -v to see
invocation)
Compiler returned: 254

The type of the static data member must be deduced (e.g. replacing `auto` with
`int` avoids the segfault; `decltype(auto)` also works in place of `auto`). The
static data member must be used (`X<void>`) to induce the segfault (e.g.
removing `int x = X<void>;` avoids the segfault).

-- 
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/20190624/4ba71d90/attachment-0001.html>


More information about the llvm-bugs mailing list