https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88822

            Bug ID: 88822
           Summary: Strange inconsistency between types of qualified
                    rvalues.
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anders.granlund.0 at gmail dot com
  Target Milestone: ---

Test case (prog.c):

  int main()
  {
    int * const         p1 = 0;
    int *       _Atomic p2 = 0;
    int * const _Atomic p3 = 0;

    struct S { int x; } s;

    s = &*p1; // Type of  &*p1  is  int * const  according to error message.
    s = &*p2; // Type of  &*p2  is  int *        according to error message.
    s = &*p3; // Type of  &*p3  is  int *        according to error message.
  }

Compilation command line:

  gcc prog.c -Wall -Wextra -std=c11 -pedantic-errors

Observations:

  The following error messages are outputed:

    incompatible types when assigning to type 'struct S' from type 'int *
const'
    incompatible types when assigning to type 'struct S' from type 'int *'
    incompatible types when assigning to type 'struct S' from type 'int *'

  From the error messages it looks like GCC thinks that the type of  &*p1  is
  int * const  and that the types of  &*p2  and  &*p3  are both  int * .

  So it seems like if the  _Atomic  qualifier is used, all qualifiers are
  removed, else they are keept.

  6.5.3.2/3 describing the special case of  &*  does not say anything about
  droping any qualifiers. However since the result of  &*  is an rvalue the
  intention of the standard was probably to remove all qualifiers always.

Reply via email to