<div dir="ltr"><div dir="ltr"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 18, 2021 at 3:47 PM Richard Kenner <<a href="mailto:kenner@adacore.com">kenner@adacore.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> I am working on it. So far I cannot find cases other than the obvious<br>
> loop hoisting ones - which C programmers can do themselves.<br>
<br>
Again, the fact that they *can* doesn't at all mean they know they should.<br></blockquote><div><br></div><div>It is easy to write bad code in C, for sure. Perhaps I have a minority opinion, but I think programmers who don't get the memory model or don't want to think about it have better alternatives than C. I really like C, but not for all purposes. There are good reasons for languages like Java, Go, Dart, etc.  where much of the low level memory stuff is left to the compiler. But there is a good reason for C, especially</div><div>when we need to work with the representations of values. </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
reasonable aliasing rules (which, by the way, will result in cleaner<br>
code), you won't have to manually create new variables in order for your<br>
program to be more efficient: you can write it in whatever way is easiest<br>
for you".<br></blockquote><div><br></div><div>The flip side is that many things that are common in C practice, even essential for writing C library functions and operating systems, are  (silently!) disabled</div><div>or made shaky by C alias rules - which is why Linux, for example, uses fno_strict_aliasing and musl relies on may_alias.  The canonical examples of problems are memcpy, allocators like malloc/free, and network packet classifiers.  Or see <a href="https://blog.regehr.org/archives/1307">https://blog.regehr.org/archives/1307</a></div><div><br></div><div>The original C aliasing rules were kind of slipped into the standard just a year or so after a pretty stiff dispute between the ANSI committee and Dennis Ritchie about aliasing, and, quite obviously, they were not completely thought out (e.g. the necessity of a hurried addition of the character pointer exception).  Anyways, my goal right now  is to understand the tradeoffs better.  </div><div>vy</div><div><br></div><div><br></div><div> </div></div></div>