Topic: Defect Report: incorrect type casts in table 32 in [lib.allocator.requirements]


Author: "Markus Mauhart" <markus.mauhart@nospamm.chello.at>
Date: 28 Feb 03 14:24:40 GMT
Raw View
 [Moderator's note: this defect report has been
 forwarded to the C++ committee. -moderator.]

I think that in par2 of 20.1.5 [lib.allocator.requirements] the last two
lines of table 32 contain two incorrect type casts. The lines are ...

  a.construct(p,t)   Effect: new((void*)p) T(t)
  a.destroy(p)       Effect: ((T*)p)-->~T()

.... with the prerequisits coming from the preceding two paragraphs, especially
from table 31:

  alloc<T>             a     ;// an allocator for T
  alloc<T>::pointer    p     ;// random access iterator
                              // (may be different from T*)
  alloc<T>::reference  r = *p;// T&
  T const&             t     ;

For that two type casts ("(void*)p" and "(T*)p") to be well-formed this would
require then conversions to T* and void* for all alloc<T>::pointer, so it would
implicitely introduce extra requirements for alloc<T>::pointer, additionally
to the only current requirement (being a random access iterator).

Therefore I think that "(void*)p" should be replaced with "(void*)&*p"
and that "((T*)p)-->" should be replaced with "(*p)." or with "(&*p)->".

Note: Actually I would prefer to replace "((T*)p)-->dtor_name" with
"p-->dtor_name", but AFAICS this is not possible cause of an omission
in 13.5.6 [over.ref] (for which I have filed another DR on 29.11.2002).
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]