Page 2 of 2

Re: Hi! Custom OS dev is cool! I wonder, what are your thoughts on compilers?

Posted: Fri Dec 05, 2025 10:28 am
by ell1e
I've never seen a compiler written directly in assembly, that's so fascinating! I wonder, is there some C code example for a code snippet that a C compiler would commonly optimize wrongly?

I'm still lurking and hoping for a compiler subforum if one were to ever show up O:) i'm currently working on a pair of two languages using the same shared compiler, but nothing's really in a super usable state yet. I hope to have an alpha working in a month or two.

Re: Hi! Custom OS dev is cool! I wonder, what are your thoughts on compilers?

Posted: Fri Dec 05, 2025 5:20 pm
by Demindiro
ell1e wrote: Fri Dec 05, 2025 10:28 am I wonder, is there some C code example for a code snippet that a C compiler would commonly optimize wrongly?
I don't have a concrete example at hand, as most code is fairly typical and a lot of bugs in mainstream compilers (GCC/Clang) get ironed out by essentially bruteforce due to how widely they are used.
Where potential issues lurk is in atypical code which may trigger paths that haven't been extensively tested. One notorious example is LLVM's noalias attribute, which Rust repeatedly tried to use yet had to disable frequently as Rust is the first mainstream language to make extensive use of it. (Though last I heard no further issues have been found).

Re: Hi! Custom OS dev is cool! I wonder, what are your thoughts on compilers?

Posted: Fri Dec 05, 2025 6:12 pm
by ell1e
Huh! I find it curious you would go so far to avoid that potential issue. But I admit I didn't ever really check if a compiler optimized something wrongly, so I don't know how prevalent that is.