Boost logo

Boost :

From: John Maddock (john_maddock_at_[hidden])
Date: 2002-05-25 05:43:24


> At 12:53 PM 5/23/2002 +0100, John Maddock wrote:
> > > enum _Ios_Seekdir { _M_ios_seekdir_end = 1L << 16 };
> > >
> > > // 27.4.2.1.5 Type seekdir
> > > typedef _Ios_Seekdir seekdir;
> > > static const seekdir beg = seekdir(0);
> > > static const seekdir cur = seekdir(SEEK_CUR);
> > > static const seekdir end = seekdir(SEEK_END);
> >
> >What? You're kidding me: surely this can't be legal code, none of
> >ios_base::beg, cur or end are valid values of ios_base::seekdir are they?
>
> The representation of an enumeration must have enough bits to hold the
> largest declared value. So with _Ios_Seekdir having an enumerator with the
> value 1 << 16, the enum must have 16 bits. As long as SEEK_CUR and
SEEK_END
> fit in 16 bits they are legal values.
>
> The reason for that rule is to allow things like:
>
> enum flags { none = 0, first = 0x01, second = 0x02, third = 0x04 };
> flags fst = flags(first | second | third);

Good point I over-reacted there, however the point is that the
implementation is almost bound to generate the rather worrying compiler
warnings that Neil reported. I can't see any easy way to suppress them
either.

John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk