http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51096
Bug #: 51096
Summary: No EBCO if a member of the base class type is defined
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: henn...@still-hidden.de
There is no EBCO if a member of the base class type is defined. I do not see
any reason why there is no EBCO in this case. It works with every other empty
struct.
MSVC++ 10 tells me that both, Derived and AnotherDerived, have a size of one
byte.
// --
#include
struct Base { };
struct Derived : public Base {
Base a;
};
struct Another { };
struct AnotherDerived : public Base {
Another a;
};
int main() {
std::cout << "sizeof(Derived): " << sizeof(Derived) << std::endl; // -> 2
Byte
std::cout << "sizeof(AnotherDerived): " << sizeof(AnotherDerived) <<
std::endl; // -> 1 Byte
return 0;
}
// ---
> g++ -v main.cpp -o main
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/src/gcc-4.6.2/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --enable-gnu-unique-object
--enable-linker-build-id --with-ppl --enable-cloog-backend=isl --enable-lto
--enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold
--disable-multilib --disable-libssp --disable-libstdcxx-pch
--enable-checking=release
Thread model: posix
gcc version 4.6.2 (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 'main' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/cc1plus -quiet -v -D_GNU_SOURCE
main.cpp -quiet -dumpbase main.cpp -mtune=generic -march=x86-64 -auxbase main
-version -o /tmp/ccmxW0pV.s
GNU C++ (GCC) version 4.6.2 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.6.2, GMP version 5.0.2, MPFR version 3.1.0-p1,
MPC version 0.9
warning: MPFR header version 3.1.0-p1 differs from library version 3.1.0-p3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../include/c++/4.6.2
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../include/c++/4.6.2/x86_64-unknown-linux-gnu
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../include/c++/4.6.2/backward
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/include
/usr/local/include
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/include-fixed
/usr/include
End of search list.
GNU C++ (GCC) version 4.6.2 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.6.2, GMP version 5.0.2, MPFR version 3.1.0-p1,
MPC version 0.9
warning: MPFR header version 3.1.0-p1 differs from library version 3.1.0-p3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: ab128873fb8cc1314e30f9032a4d831d
COLLECT_GCC_OPTIONS='-v' '-o' 'main' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
as --64 -o /tmp/ccaW2Rvd.o /tmp/ccmxW0pV.s
COMPILER_PATH=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'main' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/collect2 --build-id --eh-frame-hdr
-m elf_x86_64 --hash-style=both -dynamic-linker /lib/ld-linux-x86-64.so.2 -o
main /usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../lib/crt1.o
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../lib/crti.o
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/crtbegin.o
-L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2
-L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../lib -L/lib/../lib
-L/usr/lib/../lib -L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../..
/tmp/ccaW2Rvd.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/crtend.o
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.2/../../../../lib/crtn.o