|
|
Log in / Subscribe / Register

DeVault: Announcing the Hare programming language

DeVault: Announcing the Hare programming language

Posted May 3, 2022 15:07 UTC (Tue) by Wol (subscriber, #4433)
In reply to: DeVault: Announcing the Hare programming language by wtarreau
Parent article: DeVault: Announcing the Hare programming language

As somebody pointed out quite some while ago, compiler writers seems to be redefining defined behaviour as undefined.

What they SHOULD be doing is turning undefined behaviour into implementation defined. "On an x86_64 system, we don't check for addition overflow. You get what the hardware gives you". NOT "if you're stupid enough to add two integers both large enough for the high order bit to be set, we'll multiply them together instead then give you the middle bytes of the result". Okay, that example is facetious, but as people keep pointing out, when the programmer knows enough to put an "if ptr is null" guard in place, they do NOT want the compiler deleting it as undefined behaviour! FFS, the programmer clearly *knows* something could be wrong, and has put a test in there for it!

Cheers,
Wol


to post comments

DeVault: Announcing the Hare programming language

Posted May 3, 2022 18:24 UTC (Tue) by mathstuf (subscriber, #69389) [Link] (1 responses)

> when the programmer knows enough to put an "if ptr is null" guard in place, they do NOT want the compiler deleting it as undefined behaviour! FFS, the programmer clearly *knows* something could be wrong

And when this is stamped out code from a macro or template instantiation, should it also not be removed? What a silly optimization to leave on the cutting room floor. Compilers could probably better track this stuff to know the difference between macros and template code, but it doesn't seem to be high on the priority list right now.

DeVault: Announcing the Hare programming language

Posted May 4, 2022 15:01 UTC (Wed) by khim (subscriber, #9252) [Link]

> Compilers could probably better track this stuff to know the difference between macros and template code, but it doesn't seem to be high on the priority list right now.

It's not high on the priority list because people just couldn't agree on what things should be retained and which shouldn't be retained.

Without clear, consistent rules there are nothing to discuss. No matter what the compiler does or doesn't do there would always be someone who would claim it's wrong behavior.

DeVault: Announcing the Hare programming language

Posted May 4, 2022 14:56 UTC (Wed) by khim (subscriber, #9252) [Link]

> FFS, the programmer clearly *knows* something could be wrong, and has put a test in there for it!

What makes that test any different from many other tests which the programmer knows that the compiler knows how to remove?

There were an attempt to define a friendly C dialect. And all failed because people just couldn't agree which checks are superflous and should be removed from the program and which are important and should be retained.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds