public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101486] New: Rejects valid qualification conversion involving array of unknown bound in function template argument [P0388]
@ 2021-07-17 12:58 leni536 at gmail dot com
  2021-07-24  3:11 ` [Bug c++/101486] " pinskia at gcc dot gnu.org
  2021-07-24  3:12 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: leni536 at gmail dot com @ 2021-07-17 12:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101486
           Summary: Rejects valid qualification conversion involving array
                    of unknown bound in function template argument [P0388]
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: leni536 at gmail dot com
  Target Milestone: ---

Version:

g++
(Compiler-Explorer-Build-gcc-48e8a7a677b8356df946cd12fbb215538828e747-binutils-2.36.1)
12.0.0 20210707 (experimental)

Flags: -std=c++20 -pedantic-errors

Observed behavior:

Rejects the following code:

```
template <typename T>
void f1(const T(*)[10]);

template <typename T>
void f2(T(*)[]);

void bar(int (*ptr)[10]) {
    f1(ptr); // accepts
    f2(ptr); // rejects
}
```

Expected behavior:

Accept both function calls. Qualification conversions are allowed when deducing
template arguments in a pointer function parameter
(https://timsong-cpp.github.io/cppwp/n4868/temp.deduct#call-4.2). As of C++20
(P0388) converting `int (*)[10]` to `int (*)[]` is a valid qualification
conversion.

Exhibits:

https://godbolt.org/z/rcbMhEf45

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/101486] Rejects valid qualification conversion involving array of unknown bound in function template argument [P0388]
  2021-07-17 12:58 [Bug c++/101486] New: Rejects valid qualification conversion involving array of unknown bound in function template argument [P0388] leni536 at gmail dot com
@ 2021-07-24  3:11 ` pinskia at gcc dot gnu.org
  2021-07-24  3:12 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-24  3:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
clang and ICC reject this.
clang error message:
<source>:9:5: error: no matching function for call to 'f2'
    f2(ptr); // rejects
    ^~
<source>:5:6: note: candidate template ignored: could not match
'type-parameter-0-0 []' against 'int [10]'
void f2(T(*)[]);
     ^

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/101486] Rejects valid qualification conversion involving array of unknown bound in function template argument [P0388]
  2021-07-17 12:58 [Bug c++/101486] New: Rejects valid qualification conversion involving array of unknown bound in function template argument [P0388] leni536 at gmail dot com
  2021-07-24  3:11 ` [Bug c++/101486] " pinskia at gcc dot gnu.org
@ 2021-07-24  3:12 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-24  3:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note GCC accepts the following while both clang and ICC don't:
template <typename T>
void f1(const T(*)[10]);

template <typename T>
void f2(T(*)[]);

void bar(int (*ptr)[10]) {
    f1<int>(ptr);
    f2<int>(ptr);
}
So GCC at least is doing the conversion correctly.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-24  3:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-17 12:58 [Bug c++/101486] New: Rejects valid qualification conversion involving array of unknown bound in function template argument [P0388] leni536 at gmail dot com
2021-07-24  3:11 ` [Bug c++/101486] " pinskia at gcc dot gnu.org
2021-07-24  3:12 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).