C++ BUG: Functional cast

Nathan Sidwell nathan@acm.org
Fri Sep 10 08:41:00 GMT 1999


Hi,
picky problems with ill-formed function style casts

struct A
{
  void operator,(int);
};

void fn ()
{
  A a;
  int j;
  j = const (a,1);
  j = int (a,1);
}

1) even in pedantic mode we silently accept 'const' as a synonym for
'const int' without error or warning, even though `const' is not a
simple-type-specifier as [expr.type.conv] requires. I think we should
treat this just as `const fn();' would be (`warning ANSI forbids ...').
2) The arglist `(a,1)' is silently treated as a non-overloaded
compound-expr in the first case, it illicits a pedwarn in the second.
It's pretty obvious we should warn in both cases.
3) (More philosophical) If we do treat it as a compound-expr shouldn't
we do overload resolution on it? I think yes. That would cause these to
find A::operator, which is currently not the case.

nathan

-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
        I have seen the death of PhotoShop -- it is called GIMP
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk


More information about the Gcc-bugs mailing list