[llvm-bugs] [Bug 49369] New: __cpp_nontype_template_args >= 201907L but floating-point template arguments rejected

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 26 18:39:34 PST 2021


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

            Bug ID: 49369
           Summary: __cpp_nontype_template_args >= 201907L but
                    floating-point template arguments rejected
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Casey at Carter.net
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Clang 12.0.0-rc2 (and trunk) define __cpp_nontype_template_args to 201907L
indicating support for P1907R1 "Inconsistencies with non-type template
parameters"
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1907r1.html). This
proposal changes the constraint on non-type template arguments to require that
they have structural type, or [other cases that aren't germane] (N4878
[temp.param]/6). A _structural_ _type_ is a scalar type, or [other cases that
aren't germane] (N4878 [temp.param]/7). Scalar types include floating-point
types (N4878 [basic.types.general]/9). Nonetheless, this well-formed TU:

    template <auto> int f() { return 42; }

    int main() {
    #if defined(__cpp_nontype_template_args) && \
        __cpp_nontype_template_args >= 201911L
        return f<3.14>();
    #endif
    }

when compiled with "-std=c++2a" generates diagnostics:

    <source>:6:12: error: no matching function for call to 'f'
        return f<3.14>();
               ^~~~~~~
    <source>:1:21: note: candidate template ignored: invalid
explicitly-specified argument for 1st template parameter
    template <auto> int f() { return 42; }
                        ^
    1 error generated.

Is there any chance that either the implementation of P1907R1 could be
completed or the value of __cpp_nontype_template_args reduced (to indicate
incomplete support) in time for Clang 12?

-- 
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/20210227/85a96538/attachment-0001.html>


More information about the llvm-bugs mailing list