This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] [PR3671] Disallow conversion between enumerationtypes in template deduction


Giovanni Bajo wrote:

Hello,

[temp.arg.nontype]/5 says:

----------- QUOTE -----------
The following conversions are performed on each expression used as a non-type
template-argument. If a non-type template-argument cannot be converted to the
type of the corresponding template-parameter then the program is ill-formed.

— for a non-type template-parameter of integral or enumeration type, integral
promotions (4.5) and integral conversions (4.7) are applied
[...]
----------- UNQUOTE -----------

[conv.integral]/1 says that "An rvalue of an enumeration type can be converted
to an rvalue of an integer type", but does not allow conversion between two
different enumeration types. We are currently neglecting to disallow this, and
as a result any variable/constant of enumeration type can be used as an
argument for a template parameter of enumeration type, even if the type
mismatches. See the testcase for an example of this.

Fixed thus. Tested on i686-pc-linux-gnu with no new regressions, OK for
mainline?

OK, thanks.

--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]