Skip to content

Commit 136a828

Browse files
committed
c++: array of PMF [PR113598]
Here AGGREGATE_TYPE_P includes pointers to member functions, which is not what we want. Instead we should use class||array, as elsewhere in the function. PR c++/113598 gcc/cp/ChangeLog: * init.cc (build_vec_init): Don't use {} for PMF. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/initlist-pmf2.C: New test.
1 parent 44868e7 commit 136a828

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

gcc/cp/init.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4864,7 +4864,9 @@ build_vec_init (tree base, tree maxindex, tree init,
48644864
But for non-classes, that's the same as value-initialization. */
48654865
if (empty_list)
48664866
{
4867-
if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type))
4867+
if (cxx_dialect >= cxx11
4868+
&& (CLASS_TYPE_P (type)
4869+
|| TREE_CODE (type) == ARRAY_TYPE))
48684870
{
48694871
init = build_constructor (init_list_type_node, NULL);
48704872
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// PR c++/113598
2+
// { dg-additional-options -Wno-c++11-extensions }
3+
4+
struct Cpu
5+
{
6+
int op_nop();
7+
};
8+
typedef int(Cpu::*OpCode)();
9+
void f()
10+
{
11+
new OpCode[256]{&Cpu::op_nop};
12+
}

0 commit comments

Comments
 (0)