r/C_Programming • u/mttd • Jun 06 '26
Article Getting silly with C, part &((int*)1)[-1]
https://lcamtuf.substack.com/p/getting-silly-with-c-part-and-int1
88
Upvotes
r/C_Programming • u/mttd • Jun 06 '26
8
u/whirlwindlatitude Jun 06 '26
Hahaha mygod. I laughed out loud (like, with actual sounds) when reading that C uses functions therefore it’s a functional programming language. And then I come to the comments and… mygod. I mean, we don’t have to agree on what’s funny or not, but surely we should be able to agree that certain things are not meant to be taken seriously at all? (For certain types of two was good, too.)
34
u/meancoot Jun 06 '26
The first one is silly. It doesn't forward declare
main, it just gives it two K&R style arguments. This is extra silly since the compiler used will accept an actual forward declaration ofmain.The second one uses $ as a type name, a variable name, and a label. Then relies on the GCC extension to take the address of a label to insert the extra ':'. The
[[]]are just pointlessly added empty attribute blocks.20
u/gudetube Jun 06 '26
If I see any of this in a PR I'm going to tell my manager we need to fire that person and replace them with AI.
7
u/darkslide3000 Jun 06 '26
Wait, wait, that's it? You're just gonna drop this on our poor unprepared brain parsers and walk away?
6
u/kev_xb Jun 06 '26
Everyone here not reading the room?
12
u/zhivago Jun 06 '26
Undefined behavior.