From: Nathan Sidwell <nathan@codesourcery.com>
To: ccroswhite@get2chip.com
Cc: gcc-help@gcc.gnu.org
Subject: Re: c++, gcc3.2.2 and bitwise operations
Date: Wed, 19 Feb 2003 12:25:00 -0000 [thread overview]
Message-ID: <3E5377C5.30208@codesourcery.com> (raw)
In-Reply-To: <43834.64.169.83.2.1045618399.squirrel@webmail01.get2chip.com>
Chris Croswhite wrote:
> How can I play with the guts of a variable one bit at a time in c++? That
> is, I want to do something like this,
>
> long long val =0x4000000000000001;
> ((int*)(&val)[1]) &= 0x0;
>
> (this should set the first bit to zero). This worked with gcc 2.95.x, but I
> understand now that the casting (&val)[1] (to an array) is "undefined" and
> therefore not predictible.
>
> Could anyone give me hand?
a) read the documentation about type based aliasing
b) don't do that :)
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
next prev parent reply other threads:[~2003-02-19 12:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-19 1:36 Chris Croswhite
2003-02-19 11:56 ` Sebastian Huber
2003-02-19 12:25 ` Nathan Sidwell [this message]
2003-02-19 13:08 ` John Love-Jensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3E5377C5.30208@codesourcery.com \
--to=nathan@codesourcery.com \
--cc=ccroswhite@get2chip.com \
--cc=gcc-help@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).