Description
Reflector thread: https://lists.isocpp.org/core/2022/01/11929.php
Reference (section label): [temp.res.general]
Issue Description
In [temp.res.general] p6, it is stated that the program is ill-formed, no diagnostic required as the result of invalid constructs in templates, and:
Otherwise, no diagnostic shall be issued for a template for which a valid specialization can be generated.
The latter sentence serves no apparent purpose because the reader would not expect a diagnostic to be required if the program does not violate any of the listed conditions. Furthermore, it could be misinterpreted to mean that diagnostic messages such as optional warnings are required to be suppressed:
template <int> int foo(float x) {
return x; // warning: conversion from float to int [-Wconversion]
}
Issuing a -Wconversion
warning in this example could be seen as not conforming. Of course, an implementation could simply not treat -Wconversion
as a diagnostic as per [defns.diagnostic]. However, this interpretation means that some warnings are diagnostics and some aren't, which is contrived, and complicated for the reader.
Suggested resolution
Update [temp.res.general] p6 as follows:
[...]
-Otherwise, no diagnostic shall be issued for a template
-for which a valid specialization can be generated.
[...]