https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78620
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |aarch64-linux
Status|WAITING |NEW
Last reconfirmed|2016-12-01 00:00:00 |2017-6-8
Known to fail| |6.3.1
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed on aarch64 with
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/6.3.1/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array
--disable-libgcj --with-isl --disable-libmpx --enable-gnu-indirect-function
--build=aarch64-redhat-linux
Thread model: posix
gcc version 6.3.1 20161221 (Red Hat 6.3.1-1) (GCC)
Tweaked testcase using the correct terminology:
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <new>
void print(struct tm* tt) {
fprintf(stderr, "{%d, %d, %d, %d, %d, %d, %d, %d, %d, %ld, %p}\n",
tt->tm_sec,
tt->tm_min,
tt->tm_hour,
tt->tm_mday,
tt->tm_mon,
tt->tm_year,
tt->tm_wday,
tt->tm_yday,
tt->tm_isdst,
tt->tm_gmtoff,
tt->tm_zone);
char* p = (char*)tt;
fprintf(stderr, "%ld\n", sizeof(tm));
for (size_t i = 0; i < sizeof(tm); ++i) {
fprintf(stderr, "%02x ", (unsigned char)p[i]);
}
fprintf(stderr, "\n");
}
int main(void) {
struct tm tt1;
fprintf(stderr, "default-initialization\n");
print(&tt1);
struct tm tt2 = tm();
fprintf(stderr, "value-initialization\n");
print(&tt2);
struct tm tt3{};
fprintf(stderr, "copy-list-initialization\n");
print(&tt3);
struct tm tt4 = {};
fprintf(stderr, "value-list-initialization\n");
print(&tt4);
{
char buf[sizeof(tm)];
memset(buf, 0xFF, sizeof(tm));
new (buf) tm;
fprintf(stderr, "placement new default-initialization\n");
print(reinterpret_cast<tm*>(buf));
}
{
char buf[sizeof(tm)];
memset(buf, 0xFF, sizeof(tm));
new (buf) tm();
fprintf(stderr, "placement new with value-initialization\n");
print(reinterpret_cast<tm*>(buf));
}
{
char buf[sizeof(tm)];
memset(buf, 0xFF, sizeof(tm));
new (buf) tm{};
fprintf(stderr, "placement new with list-initialization\n");
print(reinterpret_cast<tm*>(buf));
}
}
aarch64 output:
default-initialization
{-1758476368, 127, 4197200, 0, 0, 0, -362443216, 127, -1758476340, 4197200,
(nil)}
56
b0 c7 2f 97 7f 00 00 00 50 0b 40 00 00 00 00 00 00 00 00 00 00 00 00 00 30 8e
65 ea 7f 00 00 00 cc c7 2f 97 7f 00 00 00 50 0b 40 00 00 00 00 00 00 00 00 00
00 00 00 00
value-initialization
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (nil)}
56
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00
copy-list-initialization
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (nil)}
56
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00
value-list-initialization
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (nil)}
56
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00
placement new default-initialization
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0xffffffffffffffff}
56
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ff ff ff ff
placement new with value-initialization
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (nil)}
56
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00
placement new with list-initialization
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (nil)}
56
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00
The list-initialization cases zero the padding bytes, but t he
value-initialization cases don't.