[Bug c++/94074] bogus modifying a const object error with const COMPONENT_REF

2020-03-09 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94074

--- Comment #2 from Marek Polacek  ---
And this should be diagnosed but isn't:

struct X {
  int i;
};

template 
struct S {
  const X x;
  constexpr S(int) : x{}
  {
const_cast(x).i = 19; // { dg-error "modifying a const object" }
  }
};

constexpr S p = { 10 }; // { dg-message "originally declared" }

[Bug c++/94074] bogus modifying a const object error with const COMPONENT_REF

2020-03-06 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94074

--- Comment #2 from Marek Polacek  ---
And this should be diagnosed but isn't:

struct X {
  int i;
};

template 
struct S {
  const X x;
  constexpr S(int) : x{}
  {
const_cast(x).i = 19; // { dg-error "modifying a const object" }
  }
};

constexpr S p = { 10 }; // { dg-message "originally declared" }

[Bug c++/94074] bogus modifying a const object error with const COMPONENT_REF

2020-03-06 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94074

Marek Polacek  changed:

   What|Removed |Added

   Keywords||rejects-valid
   Priority|P3  |P1
 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2020-03-06
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org
   Target Milestone|--- |10.0
 Ever confirmed|0   |1

--- Comment #1 from Marek Polacek  ---
This breaks Chromium.