This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Confusing error for incorrect struct initialization
- From: "lh mouse"<lh_mouse at 126 dot com>
- To: "Mason"<mpeg dot blue at free dot fr>
- Cc: "gcc-help"<gcc-help at gcc dot gnu dot org>
- Date: Sat, 18 Jun 2016 15:49:18 +0800
- Subject: Re: Confusing error for incorrect struct initialization
- Authentication-results: sourceware.org; auth=none
- References: <5764F614 dot 7060108 at free dot fr>
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.