Re: Strange template problem - Comeau vs EDG
[To the mods: This is a second trial to get this message into
the group. As one mod explained to me, according to his
newsreader the answer exists, but is not shown by google
newsreader. I changed the message sligthly but not it's
actual content. Feel free to remove this header]
{ The last month or so Google's Usenet archive has been unreliable, and
the non-appearance of an article or even a complete thread (!) in
Google's Usenet archive does /not/ mean it has disappeared. The earlier
posting should be available at <url:
http://groups.google.com/groups?selm=1177013000.860079.131010%40b58g2000hsg.googlegroups.com>,
but as I'm writing this Google responds "could not be found". I've
reported the general problem to Google. -mod/aps }
albrecht.fritzsche schrieb:
What does the standard says about the following
class Base {};
template <typename T>
class Derived : public T
{};
int main() {
Derived<const Base> d;
}
Is this correct Xor not correct?
The strange thing is that Comeau (and gcc and VC++ 8) compiles this
without even a warning while the EDG (and icc) triggers an error. (And
I'd thought Comeau and EDG behaved somewhat the same.)
Unfortunately I cannot find anything in the standard about this issue,
except a little note 14.1(5)
The top-level cv-qualifiers on the template-parameter are ignored when
determining its type.
This very last quote is not related to this issue, because it
concerns only non-type template-parameters.
According to the resolution of the defect report
http://www2.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#484
(which can already be found in the current draft N2134) the
intend is to allow cv qualifiers in typedef-name's.
Further on typedef-name's and type-parameter's are
synchronized according to 14.1/3:
"A type-parameter defines its identifier to be a typedef-name
(if declared with class or typename) or template-name (if
declared with template) in the scope of the template declaration.
[..]"
From this we can conclude that your example is feasible
according to the most recent interpretation, which explains
deviations in current compiler reactions.
Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]