Are there “esoteric” (weird) but standards-compliant C compilers or runtimes

cnullposixsegmentation faultstandard

As we know, the C standard does not specify a lot of details of the implementation, for example value of NULL pointer, order of bits and bytes (endiannes), alignment in structs and of stack parameters, actual organization of memory (I don't think stack layout is necessary at all, just "auto").
Additionally, some other parts are instead defined (or undefined) to produce undefined behavior, such as dereferencing null (commonly segfault but not necessarily)

Since modern platforms (or is it up to the compiler?) (intentionally?) behave similarly, some consistent behavior of programs is actually dangerous to rely on.

So, is there a unix variant or unix inspired platform, (or a compiler if it is mostly up to the compiler?) which is standard but intentionally weird to produce bugs and point out undefined behavior and unportability?
Does a similar thing exist but for POSIX instead of C? Is it even a reasonable thing to try and implement?

Best Answer

Hewlett Packard's HP-UX is the closest I can think of.

The C compiler will allow NULL-pointer dereferencing, although there was a flag to change this. The stack grew "up" (towards larger addresses) and the heap grew down (towards smaller addresses) on PA-RISC hardware.

The PA-RISC hardware had some oddities beyond stack/heap reversal, too. It had a segment register (worked differently than x86 segments) so that various libraries actually lived in different segments, and pointers-to-functions were not a single, 64-bit pointer. I don't recall if PA-RISC was as strict about pointer alignment as SPARC was, however.

On a somewhat more available level, you can use C compilers like Clang, Pcc or even Tcc, although Tcc has some problems with GNU linkers and loaders because of "weak symbols" as I understand it. At the very least, you will get different warning messages from these alternate compilers, which is always worthwhile.

You could also try alternate C libraries, like Diet Libc or Musl. I've had code do different things when compiled against Musl as opposed to GNU Libc. Both of these libraries support static linking, which GNU Libc makes difficult or impossible. Musl even has a very different dynamic linking system, which might expose latent bugs in your code.