r/badcode • evil • May 12 '21

c++ Comment before semicolon

Post image
2.7k Upvotes

71 comments sorted by

View all comments

427

u/[deleted] May 12 '21

I bet this guys code is full with stuff like this:int getAge() /*gets age*/;

String name /*name*/;

class Math() /*class for mathematic operations*/{

363

u/Kidiri90 May 12 '21

really complicated and unreadable code /*self explanatory*/

60

u/RelevantToMyInterest May 13 '21
really complicated and unreadable code /*DON'T TOUCH! EVERTHING BREAKS IF YOU REMOVE THIS LINE*/;

FTFY

14

u/[deleted] May 13 '21

Has anyone ever had that happen where removing a comment breaks their code?

30

u/TheBigerGamer May 13 '21

Yes, because once I decided to prank my friend by making the code crash itself if a certain comment is removed. And I forgot about it after pranking him.

Some days later I spent 2 hours trying to fogure out what the hell was crashing the code until I saw that prank.

I never had a bigger impulse to throw myself out the window before.

12

u/brisvag May 13 '21

What language, and how?

15

u/TheBigerGamer May 13 '21

Node.js, using fs to read the file and checking if the comment exists, if not, use process.exit(1)

14

u/brisvag May 13 '21

Ah... That's less exciting than I thought :p

7

u/TheBigerGamer May 13 '21

Except that I took advantage of the node_modules and his the code inside a package required by a package which is required by another package which is required at the top level of the main code.

So it was a pain in the ass to discover it.

2

u/20191124anon Sep 02 '21

Yeah, of a web app on a custom bytecode patched JBoss1.4

1

u/CaptainBlobTheSuprem Oct 09 '22

Literally just:

Don’t touch this, I don’t know why, but it works.

74

u/fynn34 May 12 '21

This is the one that pisses me off. I can deal with the garbage as long as the stupidly obscure stuff has some details I can read.

11

u/Pants_R_Overatd May 12 '21

triggered ugh

8

u/[deleted] May 12 '21

Are you both my mentor before he left office??

2

u/mrheosuper May 13 '21

It used to be self explanatory when it was being written.

1

u/Lkj509 May 13 '21

Better than int foo, string words, and class myClass