Issue 1102: Conditions for when types are inferred

Authors: Jay Ghiron
Date: 2026-09-01
Submitted against: C23
Status: Open

If auto appears with another storage-class specifier, or if it appears in a declaration at file scope, it is ignored for the purposes of determining a storage duration or linkage. In this case, it indicates only that the declared type can be inferred.

(C23 6.7.2 "Storage-class specifiers" paragraph 15.)

Consider the following:

int main(){
constexpr auto int x=0;
}

This should probably be invalid, but there does not appear to be any wording that actually prohibits this. Specifically, the type is inferred because another storage-class specifier appears with auto but there does not appear to be any prohibition on type inference with a type specifier. Additionally, consider the following:

int main(){
auto y=0;
}

This declaration does not have another storage-class specifier and does not appear at file scope, so it appears that the type is not inferred and therefore violates a constraint for not having a type specifier. I assume that it was not intended for this to be invalid.

There is a proposal N3579 currently that should fix these issues. The current text avoids actually defining when type inference happens, just defining when type inference can happen and applying constraints based off of if type inference happens. The following is a minimal correction that I believe will fix these issues.

Suggested correction

Modify C23 6.7.2 paragraph 15:

If auto appears with another storage-class specifier, or if it appears in a declaration at file scopeno type specifier, it is ignored for the purposes of determining a storage duration or linkage. In this case, it indicates only that the declared type can be inferred.