This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fwd: Why does gcc allow implicit conversion from const T* to T* (in C)?


> Sebastian Mach wrote:
>
> > Now my questions are:
> > 0) Is gcc just liberal?
> > 0.yes) Why?
> > 0.no) Which would be the relevant section of the standard?
>
> One thing that you may have missed is that the standard doesn't say
> anything about warnings or errors. ?When it says a translator must
> issue a diagnostic, then that can be either a warning or an error.
>

Interesting. I was unaware of that bit. In the meanwhile, "CmpDev" of
gamedev.net referenced the following point of section 6.5.16.1 (item
2):

"— the left operand has a qualified or unqualified version of a
structure or union type compatible with the type of the right"

Then, the introductory of 6.5.16.1 states "1 One of the following
shall hold"; I am confused how I should read that sentence. Does it
mean that at least one point of the following enumeration (*) shall be
true, but it's not mandatory that all hold true?

(*)
++++

6.5.16.1 Simple assignment
Constraints
1 One of the following shall hold:
— the left operand has qualified or unqualified arithmetic type and
the right has arithmetic type;
— the left operand has a qualified or unqualified version of a
structure or union type compatible with the type of the right;
— both operands are pointers to qualified or unqualified versions of
compatible types,
and the type pointed to by the left has all the qualifiers of the type
pointed to by the
right;
— one operand is a pointer to an object or incomplete type and the
other is a pointer to a
qualified or unqualified version of void, and the type pointed to by
the left has all
the qualifiers of the type pointed to by the right; or
— the left operand is a pointer and the right is a null pointer constant.
— the left operand has type _Bool and the right is a pointer.

----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]