Re: A: a new bug to old plain C
David Brown via Gcc-help <[email protected]> Mon, 8 Dec 2025 10:56:53 +0100
| Newsgroups | gmane.comp.gcc.help |
|---|---|
| Message-ID | <[email protected]> |
On 08/12/2025 04:09, Andrey Tarasevich via Gcc-help wrote: >> Further I also assume that you don't see compiler warnings as disagreeing with you? like in >> >> char *a; >> int b = a; >> # warning: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion] > > Well, once again: language-wise this is a constraint violation, i.e. a hard error. > > The fact that it is reported as a "warning" simply means that your compiler is configured > to issue a non-aborting diagnostic message for this error (aka "warning"). It is just > a quirk of the compiler. > Yes. And since it is sometimes (though rarely) necessary in code to convert a pointer to an integer type, it is an example of code where you need to use a cast to do things correctly : char * a; uintptr_t b = (uintptr_t) a; char * c = (char *) b;