Giovanni Bajo wrote:
Mark Mitchell <[EMAIL PROTECTED]> wrote:
The function type is no more
cv-qualified than any other function type; the only thing that's
cv-qualified is the type pointed to by the first argument.
The standard does not agree with you though, see 9.3.1/3.
It does indeed say that.
I've already said that it might make sense to put the cv-qualifiers in
both places, but I've also said that I think it's dangerous, because you
have to keep the two places in synch, and that's always been risky. You
also have to deal with the fact that much of the compiler may assume
function types are not cv-qualified. Furthermore, you have to be
careful of things like the fact that you cannot assign a
pointer-to-nonconst-member-function to a
pointer-to-const-member-function, even though, of course, you can assign
a "T*" to a "const T*" if "T" is an object type. So, there are still
special cases.
Furthermore, 9.3.1/3 is at odds with 3.9.3/1, which says:
Each type which is a cv-unqualified complete or
incomplete object type or is void (_basic.types_) has three corre-
sponding cv-qualified versions of its type: a const-qualified version,
a volatile-qualified version, and a const-volatile-qualified version.
Note that it explicitly leaves out function types.
Obviously, the most important thing is to get the right behavior.
Following the standard in our internal representation is secondary --
but highly desirable. In this case, my opinion is that it's a bad idea
to put the cv-qualifiers on the FUNCTION_TYPE; I'd rather see the
special cases. And, maybe, cp_type_quals should be taught about this
case -- we're already supposed to be using that in most places.
--
Mark Mitchell
CodeSourcery, LLC
[EMAIL PROTECTED]
(916) 791-8304