Skip to content

CWG2776 Substitution failure and implementation limits #1631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jensmaurer opened this issue Aug 26, 2023 · 3 comments
Open

CWG2776 Substitution failure and implementation limits #1631

jensmaurer opened this issue Aug 26, 2023 · 3 comments
Labels
EWG Evolution paper needed An issue needs a paper to describe its solution

Comments

@jensmaurer
Copy link
Member

Reaching implementation limits (even at compile-time) essentially causes IFNDR in the status quo.
A more defensive specification might be more helpful to users.

See details in CWG2776.

@jensmaurer jensmaurer added the EWG Evolution label Aug 26, 2023
@davidstone
Copy link
Collaborator

Example in which evaluation limits determine overload resolution:

constexpr int f(int max) {
	for (int n = 0; n != max; ++n) {
	}
	return 0;
}

int const x = f(1048572);
int const y = f(1048573);

template<int = x>
constexpr bool f() {
	return true;
}

template<int = y> requires true
constexpr bool f() {
	return false;
}

static_assert(f());

https://godbolt.org/z/vzf847MYc

Same example without needed global constant int:

constexpr int f(int max) {
	for (int n = 0; n != max; ++n) {
	}
	return 0;
}

template<int = f(1048572)>
constexpr bool g() {
	return true;
}

template<int = f(1048573)> requires true
constexpr bool g() {
	return false;
}

static_assert(g());

See it live: https://godbolt.org/z/441PzG517

@erichkeane
Copy link
Collaborator

EWG discussed CWG2776 during the Tuesday Morning session in Kona. The following polls were taken.

CWG2776 "Substitution failure and implementation limits" we would like to resolve this issue by making it ill-formed to hit an implementation limit (such as constexpr evaluation) and later using this 'failed constexpr" value (or a derived value) in a context where constexpr is required. A paper is required.

SF F N A SA
0 8 7 2 1

Result: Not Consensus

CWG2776 "Substitution failure and implementation limits" we would like to see a paper which makes this either IF-NDR, or well-formed.

SF F N A SA
1 6 2 2 0

Result: Consensus

@erichkeane erichkeane added the paper needed An issue needs a paper to describe its solution label Mar 18, 2024
@hanickadot
Copy link
Collaborator

EWG St. Louis: @cor3ntin volunteered to write a paper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EWG Evolution paper needed An issue needs a paper to describe its solution
Projects
None yet
Development

No branches or pull requests

4 participants