C++ PATCH for c++/48089 (ICE with invalid constexpr ctor)

Gabriel Dos Reis gdr@integrable-solutions.net
Thu Mar 17 02:43:00 GMT 2011


On Wed, Mar 16, 2011 at 9:32 PM, Jason Merrill <jason@redhat.com> wrote:
> In a normal constexpr function, we treat *this as a potential constant
> expression.  But in a constexpr constructor it isn't, since we're still in
> the process of initializing the object.

Hi Jason,
I believe the patch is too strong, or am I reading it wrong?

The real problem is that the data member of the object is not initialized.
Fully constructed subobjects in constexpr constructor are still
be potential constant expressions.
For example, we should not reject

      struct S {
           int i;
           int j;
           constexpr S(int a) : i(a), j(i*i) { }
      };

-- Gaby

> +
> +struct s {
> +    constexpr s() : v(v) { }   // { dg-error "object being constructed" }
> +    char v;
> +};
> +
> +s bang;
>
>



More information about the Gcc-patches mailing list