[llvm-bugs] [Bug 45663] New: C++20 template Constraints doesn't evaluate the current calling context

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 24 10:09:21 PDT 2020


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

            Bug ID: 45663
           Summary: C++20 template Constraints doesn't evaluate the
                    current calling context
           Product: clang
           Version: 10.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sharklienx at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Created attachment 23399
  --> https://bugs.llvm.org/attachment.cgi?id=23399&action=edit
Self-describing source code copy, from godbolt.org link.Feel free to test the
code

When a template instantiation attempt occur, the compiler seems to cache the
resulting instantiation attempt details.

The contraints evaluation along with the template are not further evaluated
correctly when further template instantiations are called, even if constraint
argument's context has changed.

This lead to valid constraint evaluation failure.
And so, it fails to instantiate specialized template, or function template
overload.


The details of such context change evaluation failure can be seen on this link
: https://godbolt.org/z/QMU6YC
(This is MAtt Godbolt's website 'Compiler Explorer')

or a copy code from that link below as an attachment.

It explains step by step my testing context, and what I expected.

This testing context focus on :
- a concept testing inheritance (with pointer conversion requires),
- a template class 'Zeta' with template constructor overload using this concept
as a constraint,

- two classes 'Alpha' and 'Beta' with inheritance relationship, but the 'Beta'
derived class is forward declared,

- some 'Ss' class definitions with a 'Zeta<Alpha>' data member,
declaring two constructors using 'Zeta<Alpha>' and 'Zeta<Beta>' as arguments,
causing 'Zeta' constrained template constructor to be evaluated as a conversion
constructor, while 'Beta' is still not defined,
Note : 'Zeta' matching type argument copy-constructor is intended.

- 'Beta' defined as derived from 'Alpha' and using 'Ss' class definition (so it
need to be defined late),

- valid 'Ss' constructors definition : using 'Zeta<Beta>' to 'Zeta<Alpha>'
constrained template conversion-constructor instantiation, as 'Beta' is now
defined as inheriting 'Alpha'.


Problem summary :
- 'Beta' inheriting 'Alpha' Constraint evaluate to false, when 'Beta' is
already defined as inheriting 'Alpha'.

Expected :
- 'Zeta<Beta>' to 'Zeta<Alpha>' constrained conversion overload is selected, as
constraints are satisfied.

-- 
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/20200424/20ad53b7/attachment-0001.html>


More information about the llvm-bugs mailing list