Jason Merrill <ja...@redhat.com> writes:

> On 12/16/2011 11:40 AM, Dodji Seketeli wrote:
>>            /* It's OK to skip a member with a trivial constexpr ctor.
>>               A constexpr ctor that isn't trivial should have been
>>               added in by now.  */
>>            gcc_checking_assert (!TYPE_HAS_COMPLEX_DFLT (ftype));
>>
>> If you think I am trying too hard, maybe I could just get out early
>> from register_constexpr_fundef if errorcount is non-zero?
>
> Let's just check errorcount in this assert.

OK, I am currently testing the patch below.

>
>> [1]:  By the way, I am just curious, why using gcc_checking_assert
>> instead of just gcc_assert?
>
> In general, I think it makes sense to use gcc_checking_assert for
> checks that either are expensive, or check conditions that aren't
> really problematic to deal with if they do occur.  But I haven't been
> particularly methodical about using one or the other.

I see.  Thanks.

gcc/cp/

        PR c++/51462
        * semantics.c (cx_check_missing_mem_inits): Don't assert in case
        of error.

gcc/testsuite/

        PR c++/51462
        * g++.dg/cpp0x/constexpr-99.C: New test.
---
 gcc/cp/semantics.c                        |    3 ++-
 gcc/testsuite/g++.dg/cpp0x/constexpr-99.C |   13 +++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-99.C

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 2f2a26a..f5d34c1 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -6021,7 +6021,8 @@ cx_check_missing_mem_inits (tree fun, tree body, bool 
complain)
              /* It's OK to skip a member with a trivial constexpr ctor.
                 A constexpr ctor that isn't trivial should have been
                 added in by now.  */
-             gcc_checking_assert (!TYPE_HAS_COMPLEX_DFLT (ftype));
+             gcc_checking_assert (!TYPE_HAS_COMPLEX_DFLT (ftype)
+                                  || errorcount != 0);
              continue;
            }
          error ("uninitialized member %qD in %<constexpr%> constructor",
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-99.C 
b/gcc/testsuite/g++.dg/cpp0x/constexpr-99.C
new file mode 100644
index 0000000..13a5ea3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-99.C
@@ -0,0 +1,13 @@
+// Origin PR c++/51462
+// { dg-options "-std=c++11" }
+
+struct A
+{
+  int i = 0;
+};
+
+struct B
+{
+  A a;
+    constexpr B() : a(0) {} // { dg-error "no matching function" }
+};
-- 
1.7.6.4



-- 
                Dodji

Reply via email to