You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
externint arr[]; // the type of arr is incompletetypedefint UNKA[]; // UNKA is an incomplete type
UNKA* arrp; // arrp is a pointer to an incomplete typeint arr[10]; // now the type of arr is completevoidbar() {
arrp = &arr; // error: different types
}
The above example is a simplified example of [basic.types#general-example-3], the comment says it's an error. However, it's valid even though their types are different. A qualification conversion can be used to convert the type of &arr to the cv-unqualified type of arrp, which obeys [expr.ass#3]
If the right operand is an expression, it is implicitly converted to the cv-unqualified type of the left operand.
The type of &arr is pointer to array of 10 int whilst the type of arrp is pointer to array of unknown bound of int, as per [conv.qual#3], the former type can be converted to the later type by a qualification conversion. Hence, the comment should be "ok". GCC is in compliance with these rules.
The text was updated successfully, but these errors were encountered:
jensmaurer
changed the title
[Editorial] The comment is wrong in [basic.types#general-example-3]
[basic.types.general] p6 Incorrect comment in example
Jul 27, 2021
[basic.types#general-example-3]
The above example is a simplified example of [basic.types#general-example-3], the comment says it's an error. However, it's valid even though their types are different. A qualification conversion can be used to convert the type of
&arr
to the cv-unqualified type ofarrp
, which obeys [expr.ass#3]The type of
&arr
ispointer to array of 10 int
whilst the type ofarrp
ispointer to array of unknown bound of int
, as per [conv.qual#3], the former type can be converted to the later type by a qualification conversion. Hence, the comment should be "ok". GCC is in compliance with these rules.The text was updated successfully, but these errors were encountered: