Bug 96959 - GCC allows ill-formed explicit capture of requires-expression local parameter
Summary: GCC allows ill-formed explicit capture of requires-expression local parameter
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2020-09-07 18:11 UTC by Hubert Tong
Modified: 2022-12-29 04:58 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-09-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hubert Tong 2020-09-07 18:11:27 UTC
A local parameter of a requires-expression is not a local entity (the name is not introduced into a block scope and is, therefore, not a variable with automatic storage duration). It is required that a simple-capture names a local entity.

GCC appears to accept simple-captures that name local parameters of requires-expressions.

Note: Even the IFNDR interpretation of this should not consider the concept to be satisfied.

### SOURCE (<stdin>):
template <typename, typename> concept C0 = true;

template <typename T>
concept C =
requires(T t) {
  [t] { };
};

static_assert(C<int>);


### COMPILER INVOCATION:
g++ -fsyntax-only -std=c++20 -Wall -Wextra -pedantic-errors -xc++ -


### ACTUAL OUTPUT:
(clean compile)


### EXPECTED OUTPUT:
(error diagnostic)


### COMPILER VERSION INFO (g++ -v):
Using built-in specs.
COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head --enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl --enable-checking=release --disable-nls --enable-lto LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200906 (experimental) (GCC)