This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Incorrect char extraction code
- To: "Rosen, Hyman" <Hyman dot Rosen at kbcfp dot com>
- Subject: Re: Incorrect char extraction code
- From: Phil Edwards <pedwards at disaster dot jaj dot com>
- Date: Mon, 29 Jan 2001 10:34:39 -0500
- Cc: "'libstdc++ at gcc dot gnu dot org'" <libstdc++ at gcc dot gnu dot org>
- References: <415C10091CFFD21193A50060083606C601AE3526@msny2.nyc.kbcfp.com>
On Mon, Jan 29, 2001 at 10:12:38AM -0500, Rosen, Hyman wrote:
>
> These are clearly wrong; the result of a static_cast<char> is not an
> lvalue, so code that tries an extraction into a signed or unsigned char
> shouldn't even compile. Those casts need to be reinterpret_cast<char &>,
> and then you need to verify that you won't run afoul of gcc's alias
> detection.
Since __c is a reference, why not static_cast<char&>(__c) instead? Then it
would be an lvalue, and we don't have to resort to reinterpret_cast.
--
pedwards at disaster dot jaj dot com | pme at sources dot redhat dot com
devphil at several other less interesting addresses in various dot domains
The gods do not protect fools. Fools are protected by more capable fools.