@aescling Can't find my thread from a few hours ago right now, but regarding NULL, I just spotted this sentence in the C89 standard:

An integral constant expression with the value 0, or such an expression cast to type void * , is called a null pointer constant. If a null pointer constant is assigned to or compared for equality to a pointer, the constant is converted to a pointer of that type. Such a pointer, called a null pointer, is guaranteed to compare unequal to a pointer to any object or function.

So combined with

NULL, which expands to an implementation-defined null pointer constant

So it actually does say that NULL is always just 0 or (void*)0!

Would be really weird if it didn't, but somehow I missed the first part and was extremely confused about why it's implementation-defined...

@vaporeon_ @aescling i think i've seen cursed compiler settings that let you define NULL to be a different address so that you can access address 0 normally, but they might be technically non-compliant

@monorail @aescling :O What kind of platform is that used on?
That sounds like it'd break a lot of existing code, things like if (!(p = malloc(123)) die("Memory alloc failed");...

@vaporeon_ @aescling i have no idea what it's used for practically, i thiiiiiink i saw it in a video about "how deep can you recurse" where they were abusing a bunch of hacks to recurse extremely deep in C but i might be mistaken

@vaporeon_ @aescling they were doing, like. "write a FUSE filesystem that does extreme compression that only works because i know exactly what's going to be here, have it report its effective size as 'almost the entire addressable space the linux kernel can see', use it as swap and assign the entire thing as stack space so we can keep recursing for days and days" lmao

Follow

@monorail @vaporeon_ 99% i like things done safely and paranoidly. but that kind of thing is the 1% of the time where you gotta let the stupid ridiculous bullshit fly and i love it

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.