Topic: Defect Report: static_cast from enum to enum
Author: wmm@fastdial.net
Date: 2000/07/06 Raw View
In article <39609263.C3C0FF0C@codesourcery.com>,
Nathan Sidwell <nathan@codesourcery.com> wrote:
>
> [ forwarded to C++ committee. -sdc ]
>
> Section: 5.2.9 expr.static.cast
> Submitter: Nathan Sidwell nathan@codesourcery.com
> Date: 3rd July 2000
>
> It appears that the following is ill-formed
> enum E1 {e1};
> enum E2 {e2};
> E2 Foo (E1 e)
> {
> return static_cast <E2> (e);
> }
> this is a surprise.
There is already an open issue on this subject. See
http://www.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#128
for the proposed solution, which differs somewhat from yours.
(This issue is in "ready" status, which means that we expect
to approve it as a defect report at the next meeting and
add the proposed resolution to the upcoming Technical
Corrigendum.)
Unless I hear otherwise from you, I will assume that this
issue and resolution adequately address your concern.
--
William M. Miller, wmm@fastdial.net
OnDisplay, Inc. (www.ondisplay.com)
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Nathan Sidwell <nathan@codesourcery.com>
Date: 2000/07/03 Raw View
[ forwarded to C++ committee. -sdc ]
Hi,
This defect report is as a result of a GCC bugreport available at
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=338&database=gcc
Section: 5.2.9 expr.static.cast
Submitter: Nathan Sidwell nathan@codesourcery.com
Date: 3rd July 2000
It appears that the following is ill-formed
enum E1 {e1};
enum E2 {e2};
E2 Foo (E1 e)
{
return static_cast <E2> (e);
}
this is a surprise.
Para 6 says that the inverse of any standard conversion sequence (other
than some exceptions) is valid. Para 7 gives the additional rule that
integer to enumeration conversion must be within the range of the
enumeration. There is no rule which allows an implicit conversion sequence
followed by the inverse of a standard conversion sequence, which is what
is required here.
Suggested Resolution:
Add an additional conversion rule explicitly permitting such conversions,
subject to the same range restrictions as integer to enumeration
conversions.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]