diff options
author | Marek Polacek <polacek@redhat.com> | 2024-07-02 15:22:39 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2024-07-10 12:34:14 -0400 |
commit | fde96e8205f343e6471a11cc9def967bb5dd5362 (patch) | |
tree | 009f3a2f04e7b22b825a2c102eb0588f974f6e8f /gcc/testsuite/g++.dg | |
parent | 9d20529d94b23275885f380d155fe8671ab5353a (diff) | |
download | gcc-fde96e8205f343e6471a11cc9def967bb5dd5362.zip gcc-fde96e8205f343e6471a11cc9def967bb5dd5362.tar.gz gcc-fde96e8205f343e6471a11cc9def967bb5dd5362.tar.bz2 |
c++: array new with value-initialization [PR115645]
This extends the r11-5179 fix which doesn't work with multidimensional
arrays. In particular,
struct S {
explicit S() { }
};
auto p = new S[1][1]();
should not say "converting to S from initializer list would use
explicit constructor" because there's no {}. However, since we
went into the block where we create a {}, we got confused. We
should not have gotten there but we did because array_p was true.
This patch refines the check once more.
PR c++/115645
gcc/cp/ChangeLog:
* init.cc (build_new): Don't do any deduction for arrays with
bounds if it's value-initialized.
gcc/testsuite/ChangeLog:
* g++.dg/expr/anew7.C: New test.
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r-- | gcc/testsuite/g++.dg/expr/anew7.C | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/expr/anew7.C b/gcc/testsuite/g++.dg/expr/anew7.C new file mode 100644 index 0000000..ead5536 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/anew7.C @@ -0,0 +1,13 @@ +// PR c++/115645 +// { dg-do compile { target c++11 } } + +struct S { + explicit S() { } +}; + +auto p = new S[1][1](); +auto q = new S[1][1]{}; // { dg-error "explicit" } +auto r = new S[1](); +auto s = new S[1]{}; // { dg-error "explicit" } +auto t = new S[1][1][1](); +auto u = new S[1][1][1]{}; // { dg-error "explicit" } |