Suspicous code in kdelibs-3.5.2
Stefan Teleman
steleman at nyc.rr.com
Wed Apr 5 19:36:48 BST 2006
On Wednesday 05 April 2006 13:57, Aaron J. Seigo wrote:
> > The C++ standard does not say anything about arrays of arrays
> > being in contiguous memory, so this is not a false positive.
>
> what platforms/compilers do we support where this isn't the case?
If the Standard does not require multidimensional arrays to be in
contiguous memory [1], an optimizing compiler on NUMA platforms can
do whatever it wants when allocating multidimensional arrays.
--Stefan
[1] ISO/IEC:14882:2003:8.3.4.9 states:
"[ Note: it follows from all this that arrays in C++ are stored
row-wise (last subscript varies fastest) and that the first subscript
in the declaration helps determine the amount of storage consumed by
an array but plays no other part in subscript calculations. ]"
The implication of this paragraph seems to be that, for a
multidimensional array declared as
T X[x][y]
an expression of type
X[x+n][y+n]
may point to an invalid address, given that the compiler is not
required to calculate this address as an offset of the first
subscript.
--
Stefan Teleman 'Nobody Expects the Spanish Inquisition'
steleman at nyc.rr.com -Monty Python
More information about the kde-core-devel
mailing list