[llvm-bugs] [Bug 47684] New: crash after hiding of class-scope using shadow declaration in a template

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 29 15:40:43 PDT 2020


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

            Bug ID: 47684
           Summary: crash after hiding of class-scope using shadow
                    declaration in a template
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Testcase causes a broken AST and a crash in IR generation:

struct A {
    void f();
};
template<typename T> struct B : A {
    using A::f;
    static constexpr auto p = &B::f;
    void f();
};
auto v = B<int>::p;

The problem is that we inject a using shadow declaration for 'using A::f', and
then try to retroactively remove it (after it was already used) when we see the
later declaration of the member 'void f()'. Then during template instantiation,
we don't instantiate the using-shadow declaration (it was already removed), so
the '&B::f' has nothing to refer to.

Perhaps the best thing to do would be to reject any case where the
UsingShadowDecl is referenced before being hidden (on the basis that this is a
"reordering the declarations changes the meaning of the class" case).

-- 
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/20200929/5625ec12/attachment.html>


More information about the llvm-bugs mailing list