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 betweenenumerationtypes in template deduction


On Wed, 7 Jul 2004 04:37:25 +0200, "Giovanni Bajo" <giovannibajo@libero.it> wrote:

> Jason Merrill wrote:
>
>>> !       /* [conv.integral] does not allow conversions between two
>>> different !   enumeration types.  */
>>> !       if (TREE_CODE (type) == ENUMERAL_TYPE
>>> !    && TREE_CODE (expr_type) == ENUMERAL_TYPE
>>> !    && !same_type_ignoring_top_level_qualifiers_p (type, expr_type))
>>> !    return error_mark_node;
>>
>> It seems wrong to special-case this.  Perhaps we should call
>> can_convert instead?
>
> At this point, we have integral types only. Is there anything but the above
> case that would be caught by can_convert?

Maybe not, but I don't care.  :)

Perhaps we could call it sooner, to deal with more types.

> Otherwise it sounds a little too heavy for such a short task. I can have
> it as an assert if you want.

It may be heavier, but it's also more maintainable.  Conversion rules
should be implemented in as few places as possible.  An important rule of
programming: don't obfuscate your code in the name of speed unless you have
actual data to show that it makes a significant difference.  As Knuth said,
"premature optimization is the root of all evil."
(http://pplab.snu.ac.kr/courses/PL2001/papers/p261-knuth.pdf, page 268)

BTW, probably can_convert_arg is a better choice, since we do have an
argument to work with.

Jason


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