[Bug c++/54590] New: Incorrect multi-inheritence bases layout

2012-09-15 Thread wingfire at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54590

 Bug #: 54590
   Summary: Incorrect multi-inheritence bases layout
Classification: Unclassified
   Product: gcc
   Version: 4.7.1
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: wingf...@gmail.com


the code:

#include 

struct A{ virtual void foo() {} };  

struct B { void * data; };

struct X : public B, A { };

int main(){

X x;
if((void*)&x == (void*)(&x.data))
std::cout << "correct\n";
else
std::cout << "oops...\n";
return 0;
}

Expect:
print "correct"

Result:
print "oops..."

Notes:
if A::foo is not virtual, the result is correct.


[Bug c++/54590] Incorrect multi-inheritence bases layout

2012-09-16 Thread wingfire at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54590

--- Comment #2 from Sun, Chaoyang  2012-09-16 
11:38:24 UTC ---
(In reply to comment #1)
> The first word contains a pointer to the vtable for X.

If the first word is the vtable of X, the memory layout should be:
{
vptr of x;
data of B;
vptr of A;
}?
but the actual layout is:
{
vptr of X and A
data of B;
}

g++ swapped the memory ordered of A and B.

also,if I have 
struct C{ virtual void foo() {} }; 
and X is defined:

struct X : public B, A,C { };

the actual layout will be:
{
vptr of X and A
data of B;
vptr of C;
}

Is it expected too? If so, it's too difficult to predicate the memory order of
each bases.


[Bug c++/54590] Incorrect multi-inheritence bases layout

2012-09-16 Thread wingfire at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54590

Sun, Chaoyang  changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |

--- Comment #3 from Sun, Chaoyang  2012-09-16 
11:40:09 UTC ---
Back to unconfirmed. Maybe it's a "feature"?


[Bug c++/69812] New: internal compiler error: Segmentation fault on Template Meta Programming

2016-02-13 Thread wingfire at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69812

Bug ID: 69812
   Summary: internal compiler error: Segmentation fault on
Template Meta Programming
   Product: gcc
   Version: lto
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: wingfire at gmail dot com
  Target Milestone: ---

Created attachment 37683
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37683&action=edit
Preprocessed file

g++ version:  
$g++-5 -v
Using built-in specs.
COLLECT_GCC=g++-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 5.3.1-8'
--with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 5.3.1 20160205 (Debian 5.3.1-8) 

OS version: Debian/sid
$uname -a 
Linux gcc 4.0.0-1-amd64 #1 SMP Debian 4.0.2-1 (2015-05-11) x86_64 GNU/Linux  

Command line:
$g++-5 -std=c++11 -save-temps -o bug bug.cpp

Error message:
bug.cpp: In instantiation of 'struct type_less':
bug.cpp:39:70:   required from 'struct partition, type_less>'
bug.cpp:62:62:   required from 'struct sort, type_less>'
bug.cpp:115:44:   required from here
bug.cpp:111:41:   in constexpr expansion of 'type_id() [with T = double]()'
bug.cpp:111:41: internal compiler error: Segmentation fault
 template struct type_less : bool_value() <
type_id()>{};
 ^
0x848ecc crash_signal
../../src/gcc/toplev.c:383
0xebc737 bool vec_safe_reserve(vec*&, unsigned int, bool)
../../src/gcc/vec.h:575
0xebc737 tree_node** vec_safe_push(vec*&, tree_node* const&)
../../src/gcc/vec.h:669
0xebc737 add_local_decl(function*, tree_node*)
../../src/gcc/function.c:6703
0x10184b3 remap_decls
../../src/gcc/tree-inline.c:653
0x12be6ae remap_block
../../src/gcc/tree-inline.c:721
0x1016f55 copy_bind_expr
../../src/gcc/tree-inline.c:794
0x1016f55 copy_tree_body_r(tree_node**, int*, void*)
../../src/gcc/tree-inline.c:1128
0x111e516 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set*, tree_node*
(*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*,
hash_set*))
../../src/gcc/tree.c:11092
0x12bf94f copy_tree_body
../../src/gcc/tree-inline.c:2966
0x12bf94f copy_fn(tree_node*, tree_node*&, tree_node*&)
../../src/gcc/tree-inline.c:6044
0xd9d380 cxx_eval_call_expression
../../src/gcc/cp/constexpr.c:1387
0xd98d6c cxx_eval_constant_expression
../../src/gcc/cp/constexpr.c:3162
0xd99479 cxx_eval_constant_expression
../../src/gcc/cp/constexpr.c:3220
0xd98a7e cxx_eval_constant_expression
../../src/gcc/cp/constexpr.c:3313
0xd9d150 cxx_bind_parameters_in_call
../../src/gcc/cp/constexpr.c:1115
0xd9d150 cxx_eval_call_expression
../../src/gcc/cp/constexpr.c:1305
0xd98d6c cxx_eval_constant_expression
../../src/gcc/cp/constexpr.c:3162
0xd984ad cxx_eval_outermost_constant_expr
../../src/gcc/cp/constexpr.c:3688
0xd0ca78 convert_nontype_argument
../../src/gcc/cp/pt.c:5917
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

Preprocessed file: attached

[Bug c++/69814] New: internal compiler error: Segmentation fault on Template Meta Programming

2016-02-13 Thread wingfire at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69814

Bug ID: 69814
   Summary: internal compiler error: Segmentation fault on
Template Meta Programming
   Product: gcc
   Version: lto
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: wingfire at gmail dot com
  Target Milestone: ---

Created attachment 37684
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37684&action=edit
Preprocessed file

g++ version:  
$g++-5 -v
Using built-in specs.
COLLECT_GCC=g++-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 5.3.1-8'
--with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 5.3.1 20160205 (Debian 5.3.1-8) 

OS version: Debian/sid
$uname -a 
Linux gcc 4.0.0-1-amd64 #1 SMP Debian 4.0.2-1 (2015-05-11) x86_64 GNU/Linux  

Command line:
$g++-5 -std=c++11 -save-temps -o bug bug.cpp

Error message:
bug.cpp: In instantiation of 'struct type_less':
bug.cpp:39:70:   required from 'struct partition, type_less>'
bug.cpp:62:62:   required from 'struct sort, type_less>'
bug.cpp:115:44:   required from here
bug.cpp:111:41:   in constexpr expansion of 'type_id() [with T = double]()'
bug.cpp:111:41: internal compiler error: Segmentation fault
 template struct type_less : bool_value() <
type_id()>{};
 ^
0x848ecc crash_signal
../../src/gcc/toplev.c:383
0xebc737 bool vec_safe_reserve(vec*&, unsigned int, bool)
../../src/gcc/vec.h:575
0xebc737 tree_node** vec_safe_push(vec*&, tree_node* const&)
../../src/gcc/vec.h:669
0xebc737 add_local_decl(function*, tree_node*)
../../src/gcc/function.c:6703
0x10184b3 remap_decls
../../src/gcc/tree-inline.c:653
0x12be6ae remap_block
../../src/gcc/tree-inline.c:721
0x1016f55 copy_bind_expr
../../src/gcc/tree-inline.c:794
0x1016f55 copy_tree_body_r(tree_node**, int*, void*)
../../src/gcc/tree-inline.c:1128
0x111e516 walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*),
void*, hash_set*, tree_node*
(*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*,
hash_set*))
../../src/gcc/tree.c:11092
0x12bf94f copy_tree_body
../../src/gcc/tree-inline.c:2966
0x12bf94f copy_fn(tree_node*, tree_node*&, tree_node*&)
../../src/gcc/tree-inline.c:6044
0xd9d380 cxx_eval_call_expression
../../src/gcc/cp/constexpr.c:1387
0xd98d6c cxx_eval_constant_expression
../../src/gcc/cp/constexpr.c:3162
0xd99479 cxx_eval_constant_expression
../../src/gcc/cp/constexpr.c:3220
0xd98a7e cxx_eval_constant_expression
../../src/gcc/cp/constexpr.c:3313
0xd9d150 cxx_bind_parameters_in_call
../../src/gcc/cp/constexpr.c:1115
0xd9d150 cxx_eval_call_expression
../../src/gcc/cp/constexpr.c:1305
0xd98d6c cxx_eval_constant_expression
../../src/gcc/cp/constexpr.c:3162
0xd984ad cxx_eval_outermost_constant_expr
../../src/gcc/cp/constexpr.c:3688
0xd0ca78 convert_nontype_argument
../../src/gcc/cp/pt.c:5917
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

Preprocessed file: attached