public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "John Yates" <jyates@netezza.com>
To: "Eljay Love-Jensen" <eljay@adobe.com>,
	"Ulf Magnusson" <ulfalizer@gmail.com>, <gcc-help@gcc.gnu.org>
Subject: RE: Strange shifting behaviour
Date: Wed, 13 Jul 2005 18:10:00 -0000	[thread overview]
Message-ID: <F0CD2E5262214F44959AD6AF34ADA66E01D13105@mail2.netezza.com> (raw)

Eljay,

Though I agree with your point about the standards and
undefined behavior, I do believe that Ulf has identified
a quality of implementation issue.

Would you not agree that compile-time expression evaluation
should mimic run-time as much as possible?  Or to put it
another way, the more often compile-time and run-time
evaluated results diverge, the lower the subject quality
of the compiler.

If the shift operator at run-time examines only the lower
order 5 bits of the shift count (as Ulf's x86 does) then
a "high-quality" compile-time expression evaluator ought
to do the same.

/john

-----Original Message-----
From: Eljay Love-Jensen [mailto:eljay@adobe.com]
Sent: Tuesday, July 12, 2005 6:46 PM
To: Ulf Magnusson; gcc-help@gcc.gnu.org
Subject: Re: Strange shifting behaviour


Hi Ulf,

>When shifting an int by its size in bits...

That is undefined behavior (implementation dependent), as per C and C++ standards.  Ever since C was first taking it's first baby steps.

By "undefined behavior", that means any given particular implementation can:
+ not do anything
+ do what you expect
+ SEGV
+ format your hard drive

--Eljay

             reply	other threads:[~2005-07-13 18:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-13 18:10 John Yates [this message]
2005-07-13 18:20 ` corey taylor
  -- strict thread matches above, loose matches on Subject: below --
2005-07-13 18:47 John Yates
2005-07-13 19:00 ` Eljay Love-Jensen
2005-07-13 19:01 ` corey taylor
2005-07-12 22:34 Ulf Magnusson
2005-07-12 22:44 ` Eljay 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=F0CD2E5262214F44959AD6AF34ADA66E01D13105@mail2.netezza.com \
    --to=jyates@netezza.com \
    --cc=eljay@adobe.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=ulfalizer@gmail.com \
    /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).