https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90426

            Bug ID: 90426
           Summary: [P0732] Error constructing non-type template parameter
                    from a prvalue
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mateusz.pusz at gmail dot com
  Target Milestone: ---

Hi,

Compiling the code provided below with the following options produces an error:
"-std=c++2a -Wall -Wextra"

```
#include <ratio>

struct ratio {
    std::intmax_t num;
    std::intmax_t den;

    template<std::intmax_t Num, std::intmax_t Den>
    constexpr ratio(std::ratio<Num, Den>): num(Num), den(Den) {}
};

template<auto R>
struct unit {};
struct gram : unit<ratio(std::milli())> {};
```

Error:
<source>:13:39: error: type/value mismatch at argument 1 in template parameter
list for 'template<auto R> struct unit'

   13 | struct gram : unit<ratio(std::milli())> {};

      |                                       ^

<source>:13:39: note:   expected a constant of type 'auto', got
'ratio(std::milli (*)())' {aka 'ratio(std::ratio<1, 1000> (*)())'}

Compiler returned: 1

See also here: https://godbolt.org/z/PHD8Ly

Best

Mat

Reply via email to