Hi Dan,
On 3/13/23 13:19, Dan Cross wrote:
On Mon, Mar 13, 2023 at 6:41 AM Alejandro Colomar
(man-pages)
<alx.manpages(a)gmail.com> wrote:
Or you can ask GCC to respect your view of the
language with things like -fno-strict-aliasing, -fwrapv, and -fno-trapv.
The problem that is that you are then no longer programming in "C",
but rather some dialect of "C" that happens to share the same syntax,
but with different semantics. That may be fine, or it may not, but it
can lead to all sorts of footgun traps if one is not careful.
Well, it depends on what you call "C". There are many dialects,
and I'm not sure there's any which I'd call "C".
The 3 main dialects are "ISO C", "GNU C", and "K&R C".
And then
there are subdialects of them. We could say "C" is "ISO C", since,
well, it's _the_ standard. But then, ISO C shares the aliasing
issues that GNU C has, so by avoiding the GNU C compiler you're
not avoiding the issues we're talking about; moving to a compiler
that only talks ISO C is going to keep the issues. You'll need
a compiler that talks K&R C, or some other dialect that doesn't
have aliasing issues.
At that point, since you already need a subdialect of C, GCC is
one such compiler, since it provides a comprehensive set of flags
to tune your dialect.
Or you could move to a compiler that talks its own dialect
(probably some subdialect of K&R C, as I expect Plan9 C is, but
I never tried it). But that's not much different from asking
such dialect to GCC.
Cheers,
Alex
- Dan C.