Re: Meaning of memset



James Kuyper <jameskuyper@xxxxxxxxxxx> writes:

Ark Khasin wrote:
...
Is it so that a consensus emerges that ^ | & on negative numbers
depend

I can't speak for the consensus; this is just my understanding of what
the standard says. In many cases my understanding differs distinctly
from the consensus understanding.

on representation (or, to tell the truth, act on representations)
and so are implementation-defined (although only 3 ways to implement
are recognized)?

Those operators don't act on the representations of objects; otherwise
cases like

x += (a+1) | (b-2);

You have written a correct statement because, of course, a+1 is not an
object. The question is, does '(a+1) | (b-2)' depend (or act) on the
representation of 'a+1' and 'b-2' and I'd say it does.

Section 6.2.6 is called "Representations of types" (not objects) and
6.2.6.1 p4 takes some pains to define a new term -- the "object
representation" -- which is not quite the same thing as the
representation of the type.

I don't want to suggest that | operates on padding bits. I don't
think one can determine that either way, but it seems to be pushing the
meaning of representation to its limits (and beyond that used in the
standard) to say that |, &, and ^ act on the value not the
representation.

would be undefined. The way that they operate on or generate negative
values must, however, be consistent with whichever of 3 permitted ways
of handling the sign bits that the implementation chose for the
relevant type.

These "permitted ways" are described in the section called
"Representation of types". Your sentence would be simpler if you had
said that the bits they operate on (and the meaning of the bits that
are produced) are determined by the representation used for signed
integer types.

It is possible to define the result of | on signed types by talking
only about the value of the operands, but it is complicated to do so
and the standard clearly distinguishes between the terms
"representation" and "object representation" so that there is simple
way to understand the operation. The standard uses only few words to
define | (and the others) because the term "corresponding bits" is
clearly intended to refer back to the bits used to represent the
value as described in 6.2.6.

I see no way for those operators to operate on the
padding bits in any sense that is meaningful within the context of the
standard.

I agree, but padding bits are only one part of the representation of
the type.

--
Ben.
.



Relevant Pages

  • Re: Transfer and variables that dont use all their storage space.
    ... the standard that I'm hoping someone here can comment on. ... cannot "normalize" the bit representation into one of the canonical ... except with your comment that the para before is incorrect. ...
    (comp.lang.fortran)
  • Re: Three questions about signed/unsigned type representations
    ... The C++ standard does not ... specify the internal representation of many types of objects, ... "Types bool, char, wchar_t, and the signed and unsigned integer types ... value for that type, causes undefined behavior. ...
    (comp.lang.cpp)
  • Re: significant digits
    ... This is an international standard since 1985. ... even standardized until after the current version Matlab was released! ... IEEE 754 defines several rounding modes, ... you will have to truncate the expansion, and at that point the representation ...
    (comp.soft-sys.matlab)
  • Re: PGI wierdness with .EQV.
    ... representation requirements on C's _BOOL type. ... KIND) is not specified by the standard, ... no deficiencies and the other way is to make it so complicated ...
    (comp.lang.fortran)
  • Re: ptr conversions and values
    ... >>> Well, fortunately the standard says no such thing, and therefore I don't ... > A representation is a mapping from a bit pattern to a some target set. ... A pointer represents memory ...
    (comp.std.c)