c++ - Are narrowing conversions in non-type template parameters required to be diagnosed? -
This is almost certainly a duplicate but it does not provide a satisfactory answer. In reply, it is not known that GCC Whether it is wrong to not provide clinical or not, only gives a warning flag which is an option to some degree.
Related sections of standard:
§14.3.2 / 5
A non-type template-parameter of an integral or calculated type For, conversions that are allowed in an integrated continuous expression (5.1 9) apply.
§ 5.1 9/3
A continuous expression of type T is a literal continuous expression, the inherent type converted into T, where the underlying conversion (if Someone is allowed) In a literal continuous expression and built-in conversion sequence, only user-defined conversions, conversions other than narrow conversions (8.5.4) (4.9), integral promotion (4.5), integral promotion (4.7), live -Two-Rivalue Conversions (4.1) P>
A narrow conversion in situations under normal circumstances will make a program worse, but there is a clear lapse in it, so compile RSS disagree (GCC is not a clinical Rubbing makes an error, MSVC also does not provide any diagnostic.) Is there a language in the standard that says for this condition, a diagnosis is necessary (i.e., it is ill Made it)?
#include & lt; Array & gt; Int main () {std :: arrays & lt; Int, -1 & gt; a; } As the word expression has already been changed to make it clear,
n3337 The result was bad (§ 14.3.2 / 5):
The following conversions are made on each expression used as a non-type template-logic. If a non-type of template-logic can not be converted to the same template-parameter type, then the program is poorly formed.
Since it specifies that the programs are bad, and do not allow specific permission to do the opposite, a diagnosis is necessary to violate it (per.1.4 / 1):
There are all syntax and financial rules in the set of diagnostic rules, except for those standards there is a clear signaling that "there is no diagnostic requirement" or about It is described, Asit behavior. " Line
FWIW, note that they have also separated the definition of acceptable conversions from those people for conversion. Constant Expression - Potential Conversions are now listed directly in 14.3.2 / 5.
Comments
Post a Comment