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]

Re: Confusing error for incorrect struct initialization


Those are GCC implementation details.

In spite that in most cases implicit conversion from an integer (except a null pointer constant, of course) to a pointer should be considered a casual error, it is however required by the C standard:
---
ISO/IEC WG14 N1570 Programming languages â C

6.3 Conversions
1 Several operators convert operand values from one type to another automatically. This
subclause specifies the result required from such an _implicit conversion_,  ...
...

6.3.2.3 Pointers
5 An integer may be converted to any pointer type. Except as previously specified, the
result is implementation-defined, might not be correctly aligned, might not point to an
entity of the referenced type, and might be a trap representation.67)
---

Making it an error would make GCC not conform to the standard just because C is so broken.


------------------				 
Best regards,
lh_mouse
2016-06-18

-------------------------------------------------------------
åääïMason <mpeg.blue@free.fr>
åéææï2016-06-18 15:19
æääïGCC help
æéï
äéïConfusing error for incorrect struct initialization

Hello,

I opened bug 71552:

Confusing error for incorrect struct initialization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71552

I don't understand Martin's reply in comment #1.

Could someone explain?

Regards.



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