------- Comment #6 from terra at gnome dot org  2009-11-03 17:44 -------
cp/class.c has code like this:

/* If any field is const, the structure type is pseudo-const. * /
if (CP_TYPE_CONST_P (type))
  {
    ...
    /* ARM $12.6.2: [A member initializer list] (or, for an
       aggregate, initialization by a brace-enclosed list) is the
       only way to initialize nonstatic const and references
       members.  */
    TYPE_HAS_COMPLEX_ASSIGN_REF (t) = 1;
  }

The ARM comment (as quoted) is clearly wrong: offhand, I can think of
two other ways of getting an object initialized.  There are probably
more.

1. Casting the offending "const" away.  (Note that struct A is a plain
   old C type -- data members only.)

   // Make an object of type A.
   A *pa = (A *)malloc (sizeof (A));
   *const_cast<int *>(&pa->x) = 42;
   pa->y = 42;

2. Copying an existing object.

   A a (*pa);

I don't see the justification for setting TYPE_HAS_COMPLEX_ASSIGN_REF,
just for prohibiting assignment.  That's pretty much the mixup I was
claiming in comment 4.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39934

Reply via email to