public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] Fix for short-enums comparison bug
@ 1999-02-11 12:12 Mike Stump
  1999-02-28 22:53 ` Mike Stump
  0 siblings, 1 reply; 26+ messages in thread
From: Mike Stump @ 1999-02-11 12:12 UTC (permalink / raw)
  To: egcs, law

> To: Charles G Waldman <cgw@alum.mit.edu>
> Date: Thu, 11 Feb 1999 00:46:40 -0700
> From: Jeffrey A Law <law@hurl.cygnus.com>

> I'm not a language lawyer -- we really need one to determine what
> the behavior of that code should be.

I disagree.  The gcc documentation has enough.  It says that a
integral number of bytes are used to represent the enum.  And only if
it were a bit field, would an integral number of bits be used.

If a byte is used 4+1 = 5, 5 is > 4, so the loop must stop.  If we
used bitfields, 4+1=0 (when we use 2 bits for the enum).  But the
documentation clearly states and the users expectation is we use a
byte.

Now, if we want to change to document, we _can_ entertain this, and we
can allocate just the number of bits required.  We are allowed to do
this optimization in C++ certainly (if the user can't otherwise tell).
If we do this, then the behavior of the program _is_ correct.

> Date: Thu, 11 Feb 1999 10:31:58 -0700
> From: Jeffrey A Law <law@hurl.cygnus.com>

> Yes the underlying type must be capable of representing all the
> values for the enum.  But does the enum restrict the actual values
> which can be used with the expected results?

It does (for C++), but we don't need to make use of that much latitude
in the standard.  It we can reasonably maye _more_ code work, even
though strickly speaking it isn't portable, we should.

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~1999-02-28 22:53 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <x490ee6l2e.fsf@janus.pgt.com>
1999-02-10 23:47 ` [PATCH] Fix for short-enums comparison bug Jeffrey A Law
     [not found]   ` < 4691.918719200@hurl.cygnus.com >
1999-02-11  6:55     ` Gavin Romig-Koch
     [not found]       ` < 14018.60839.325601.426391@cetus.cygnus.com >
1999-02-11  7:25         ` Joern Rennecke
1999-02-28 22:53           ` Joern Rennecke
1999-02-11  8:12         ` Charles G Waldman
1999-02-28 22:53           ` Charles G Waldman
1999-02-11  9:33         ` Jeffrey A Law
     [not found]           ` < 5858.918754318@hurl.cygnus.com >
1999-02-11 11:40             ` Gavin Romig-Koch
1999-02-28 22:53               ` Gavin Romig-Koch
1999-02-11 11:44             ` Joe Buck
     [not found]               ` < 199902111942.LAA16560@atrus.synopsys.com >
1999-02-11 11:55                 ` Jeffrey A Law
     [not found]                   ` < 6271.918762821@hurl.cygnus.com >
1999-02-11 12:07                     ` Joe Buck
1999-02-28 22:53                       ` Joe Buck
1999-02-11 14:16                     ` Tim Hollebeek
     [not found]                       ` < 199902112216.RAA27319@wagner.Princeton.EDU >
1999-02-11 14:19                         ` Jeffrey A Law
     [not found]                           ` < 6754.918771465@hurl.cygnus.com >
1999-02-11 17:03                             ` Joe Buck
1999-02-28 22:53                               ` Joe Buck
1999-02-28 22:53                           ` Jeffrey A Law
1999-02-28 22:53                       ` Tim Hollebeek
1999-02-28 22:53                   ` Jeffrey A Law
1999-02-28 22:53               ` Joe Buck
1999-02-28 22:53           ` Jeffrey A Law
1999-02-28 22:53       ` Gavin Romig-Koch
1999-02-28 22:53   ` Jeffrey A Law
1999-02-11 12:12 Mike Stump
1999-02-28 22:53 ` Mike Stump

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).