operator new() alignment of PPC32

Andrey Tsyvarev tsyvarev@ispras.ru
Wed Nov 19 15:28:00 GMT 2008


Hello,

I have a question about alignment restriction of storage, allocated by
::operator new(size_t size).

Standard says, that this operator should

"allocate size bytes of storage suitably aligned to represent any
object of that size".

On PPC32 architecture there is a 'long double' type, which, according
to documentation ("SYSTEM V APPLICATION BINARY INTERFACE PowerPC
Processor Supplement"), should have size and alignment equal to 16
bytes.
But on this architecure ::operator new(16) may return address, which
aligned only on 8, not 16 bytes.

This fact is difficult to call a bug, because of many reasons.
E.g. behaviour of malloc() is known to be the same. One of the reasons
is that 'long double' type is rarely used in programs, and for
special cases there is posix_memalign() function.

But why does ::operator new() return misaligned address?
Rare using of long double, too? Or compatibility with malloc()?
Or are there other reasons for such behaviour?

Thank you in advance
-- 
Andrey Tsyvarev
 
 Linux Verification Center, ISPRAS
 web:    http://www.linuxtesting.org
 e-mail: tsyvarev@ispras.ru



More information about the Libstdc++ mailing list