Confusing error for incorrect struct initialization
lh mouse
lh_mouse@126.com
Sat Jun 18 07:50:00 GMT 2016
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.
More information about the Gcc-help
mailing list