Bug 115594 - requires expression permits arrays of voids
Summary: requires expression permits arrays of voids
Status: RESOLVED DUPLICATE of bug 24664
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 14.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks: 24666 concepts
  Show dependency treegraph
 
Reported: 2024-06-22 21:32 UTC by Fedor Chelnokov
Modified: 2024-06-27 04:03 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fedor Chelnokov 2024-06-22 21:32:29 UTC
This program
```
template<typename T>
concept C = requires(T t[2]) {
    t;
};

static_assert(!C<void>);
```
seems valid because arrays of voids are not allowed, and it is accepted by Clang and MSVC. But in GCC static_assert evaluates to opposite value. Online demo: https://gcc.godbolt.org/z/nM8Mj8qrb
Comment 1 Andrew Pinski 2024-06-22 21:41:09 UTC
The interesting thing is the reason why clang outputs:
<source>:2:25: note: because 't' would be invalid: array has incomplete element type 'void'


Is not exactly correct as if you change void to being a incomplete type:
struct A;

static_assert(C<A>);

it is accepted by all compilers ...
Comment 2 Andrew Pinski 2024-06-22 21:53:10 UTC
I think this is a dup of bug 24664.
Comment 3 Andrew Pinski 2024-06-27 04:03:58 UTC
Yes it is a dup.

The following should also be rejected but currently is not:
```
  template<class T, class T1 = int*(T[5])> int f(T*);
  int j=f<void>(nullptr);
```

Basically function arguments (including concepts "arguments") decay too early for arrays to pointers.

*** This bug has been marked as a duplicate of bug 24664 ***