[Bug c++/21514] templates and anonymous enum

papadopo at shfj dot cea dot fr gcc-bugzilla@gcc.gnu.org
Wed May 18 09:33:00 GMT 2005


------- Additional Comments From papadopo at shfj dot cea dot fr  2005-05-18 09:33 -------
I'm not sure what a DR is, probably a C++ standard defect report. After asking
on fr.comp.lang.c++ I was referred to Core Issue 278:
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#278

Whether the compiler should compile the code or not, the error message really
needs to be improved. My understanding of the situation is that :

1.a) The compiler first attempts to apply the shift operator to integer "i".
However the right-side argument is an anonymous enum. The compiler will not
implictly cast the anonymous enum to a size_t to be used as the right-hand
argument for operator<<.

1.b) Note that an *explicit* cast does work, so I'm not sure how this whole
issue is related to Core Issue 278 and external linkage. Just change from:
    i<<HSize;
to:
    i<<int(HSize);
and the program while compile and link.

2) The compiler then attemps to use operator<<(MyClass& b, const T& t). Instead
of reporting an error on the first argument (type 'MyClass' expected, type 'int'
actually used), it reports an obscure error on the second argument. This is
totally non-intuitive for humans.

Therefore:

* Concerning 1.a) and 1.b) I'm not convinced this is related to Core Issue 278
and external linkage since the explicit cast works. Anyway, if you feel Core
Issue 278 or some paragraph of the standard forbid the implicit cast, I agree
this bug report should be kept open until the comitee resolves the problem.

* In the meanwhile, the error message really needs to be improved, taking into
account point 2).


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|SUSPENDED                   |NEW


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21514



More information about the Gcc-bugs mailing list