Re: A debugging implementation of malloc



<ena8t8si@xxxxxxxxx> wrote in message
news:1153168957.503281.293600@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Chris Torek wrote:
Barry Schwarz wrote:
At this point [where r is the result of a malloc() call] r contains
the address of a block of memory properly aligned for any possible
object.

In article <4g5uc3F1m0bt2U1@xxxxxxxxxxxxxx>
Ian Collins <ian-news@xxxxxxxxxxx> wrote:
Is there a portable way of finding out what this alignment is?

No. I consider this a flaw in the C standards.

If there *were* a portable way to find this, you could write portable
"augmented malloc and free" routines along the lines of those Mr Navia
has provided (with more work to deal with alignment, of course). ...

I think you mean to add a qualifier that pointers
can be turned into integers and operated on sensibly.
Otherwise knowing the alignment doesn't help.

Dumb question:

If we have no guarantee of modular math on the pointers, then why not
repeated subtraction on the pointers (which is clearly guaranteed)?



.



Relevant Pages

  • Re: [JW] alignment problem for structures
    ... > alignment restriction for the pointer or for the referred-to type? ... the alignment requirements of pointers to void and pointers to character ... > be treated as an array of one element. ...
    (comp.std.c)
  • Re: ptr conversions and values
    ... it's OK to think of all object pointers as pointing to a byte. ... By adding a forbidden assignment to an allowed conversion? ... > types shall have the same representation. ... > and having the same representation and alignment ...
    (comp.std.c)
  • Re: Spacing in derived data types, using SEQUENCE attribute, for MPI
    ... Does not guarantee against padding, ... 6.5.8p5 When two pointers are compared [that constraints allow to be ... pointers to structure members declared later compare greater than ... I have heard of no C++ compiler that doesn't keep it for ALL structs ...
    (comp.lang.fortran)
  • Re: [JW] alignment problem for structures
    ... When the standard says "a pointer to ... >> alignment restriction for the pointer or for the referred-to type? ... > the alignment requirements of pointers to void and pointers to character ... > have addresses that are particular multiples of one?... ...
    (comp.std.c)
  • Re: Pointer equality and dereferencing
    ... It's meant to guarantee that they compare equal. ... 6.2.6.1p4 does not guarantee that pointers which ... but it does state that pointers with identical representations ... Please state where the standard guarantees that p1 and p2 are ...
    (comp.std.c)