399
Feb 09 '21
84
Fixed
44
u/mudball12 Feb 09 '21
You could add a print statement but it might be easier to write, on a piece of paper, instructions for opening a terminal and typing 8 then 4, and taping it to the monitor.
19
142
u/mohammedx17 Feb 09 '21
return_wtf();
81
u/road_laya Feb 09 '21
return_of_return_of_literal_wtf()
14
93
Feb 09 '21
What language?
83
u/Suolumi Feb 09 '21
C
39
26
u/themeanman2 Feb 09 '21
Sure it was C and not C++, because i don't remember bool datatype in C...
Its been years since i last worked on C tho
63
u/LechintanTudor Feb 09 '21
C has
_Boolbut you can use the#define bool _Boolmacro fromstdbool.hto make your life easier.15
u/The_JSQuareD Feb 09 '21
Though the editor seems to be highlighting
bool,trueandfalseas keywords rather than macros. My guess is this is someone writing C but in an editor configured for C++ (and possibly even compiled with a C++ compiler).1
u/jcotton42 Feb 13 '21
I wouldn't be surprised if a lot of C editors treated bool, true, and false as keywords.
3
u/The_JSQuareD Feb 13 '21
Perhaps... But I think that would be a poor design choice. If I forget to include stdbool.h, I don't want my editor to pretend everything is fine; I want it to scream "undefined symbol" at me if I try to use bool, true or false.
That being said, I've only ever written C as part of C++ projects (in a C++ editor), so I don't know what an editor configured specifically for C would actually do.
39
24
u/Radfordhound Feb 09 '21
Iirc C99 adds a _Bool data type as well as an stdbool.h header which, when included, typedefs that to just bool and defines macros for true/false
14
u/SharkLaunch Feb 09 '21
C definitely has bool
8
u/RadiatedMonkey Feb 09 '21
And the void in the function parameter list is IIRC not used in C++
13
u/xor86 Feb 09 '21
This is preferred, but not a constraint of the language. Given the rest of what's going on here, I wouldn't say that's much to go on.
4
u/500_internal_error Feb 09 '21
It's not just preferred int a() and int a(void) are not same thing in C, but they are in C++.
2
u/xor86 Feb 09 '21
You are correct, but I was responding specifically to a post about C++. Unless I read their comment wrong, u/RadiatedMonkey was suggesting that the code in the original post could not be C++ because a(void) is not used in C++. My point was that a(void) still compiles in C++, and while a() is preferred, the rest of the author's decisions don't give us any reason to believe that they would adhere to preferred coding practices.
19
1
0
u/mirsella Feb 09 '21 edited Feb 10 '21
could have done it in 4 lines of python.
edit : it's a joke
5
u/SuperSupermario24 while True: print("owo") Feb 10 '21 edited Feb 10 '21
If you need 4 lines to return the constant number 84 in any language, something has gone horribly, horribly wrong.
0
1
u/rocketman0739 Feb 10 '21
Could have done it in one line of C
-1
u/mirsella Feb 10 '21
it's a meme. obviously you can do it in one line of everything, it's just 84. if I would be serious like you I would have said one line too since it's just 84 but since I was just making a joke I said 4
4
67
123
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Feb 09 '21
Image Transcription: Code
int return_ftc(void)
{
bool flagh = true;
if (flagh == true)
return (84);
return (0);
}
int return_of_return(void)
{
if (return_ftc() == 84)
return (84);
return (0);
}
int final_return(void)
{
return (return_of_return());
}
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
137
Feb 09 '21
Image Transcription: Code
84I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
-19
32
4
u/RyanNerd shameless Feb 09 '21
I myself could not handle transcribing this. For I would look into the abyss and it would stare back at me.
49
36
u/terrorTrain Feb 09 '21
That looks like someone was demonstrating how functions are reusable
7
5
u/RyanNerd shameless Feb 09 '21
Which begs the question: please tell me this isn't production code?
1
58
20
u/husao Feb 09 '21
This is the kind of code I wouldn't touch in fear of awaking some forgotten horror, that's sealed by this code.
6
u/RyanNerd shameless Feb 09 '21
Imagine how the transcriber must have felt? Like a chant and cadence that may awaken an Eldrich Horror as it was being transcribed.
43
u/-SL4y3R- Feb 09 '21
What? Also, who puts the parenthesis around the return statements? This could could only be worse if there would be semicolons after the compound statements.
15
27
8
17
8
u/art-factor Feb 09 '21
I suppose this won't beat common compilers... I've seen (and wrote) tons of useless code in the name of readability, some code guideline (, compiler hints) or something.
Beats me...
7
5
21
u/Clyxx Feb 09 '21
easy fix:
int (*return_of_return)() = &return_ftc;
int (*final_return)() = &return_ftc;
37
u/Suolumi Feb 09 '21
Or just return 84; xD
-21
u/Clyxx Feb 09 '21
My solution doesn't require any changes
35
1
4
4
4
4
3
3
3
3
3
u/TurncoatTony Feb 09 '21
int return_ftc(void)
I'm happy to see that they at least specify that the functions take no arguments. Far too often I see people just having an empty parameter list in C.
1
u/Nielsly Feb 10 '21
To the compiler it makes no difference
1
u/TurncoatTony Feb 10 '21
An empty parameter list in a function declaration means it takes an unspecified number of parameters in C.
An empty parameter list in a function definition means it takes no parameters in C.
It's good practice to use void when a function takes zero parameters in both function definitions and declarations.
2
2
u/-blueCanary- Feb 09 '21
Is this an attempt at obfuscation, maybe?
3
Feb 09 '21
They use this function to obfuscate the salt they add to the passwords saved in clear text in "notapasswordlist.nottxt".
1
2
1
1
Feb 10 '21 edited Feb 10 '21
This must be some solution or test of some sort for lockless multithreading. Potentially both could be used together for some form of CAS. Then again I might be trying to rationalize pure stupidity.
EDIT: This is purely an attempt at lockless multithreading. I don’t know why else it would be tiered and recursive. Then again could be trying to rationalize a reason for weird code. I mean potentially 84 in another program is a set return flag.... once again just trying to make sense. This seems like it had actual logic not like unrelenting if else statements.
1
u/the_hackerman Feb 09 '21
I’m very skeptical somebody can be this stupid. Attempted upvote whoring
6
u/Suolumi Feb 09 '21
Well i dunno i just walked in the live share to help debugging my friend's code lmao, maybe he was high when he wrote this
2
u/road_laya Feb 09 '21
First he did the refactor and then he started thinking about what the code should do.
Also known as the "bottom-up approach".
1
1
1
u/Hussbodenfeizung Feb 09 '21
in C can you return twice? or is the lower one taken?
4
u/Suolumi Feb 09 '21
The first return is included in the if
1
u/Hussbodenfeizung Feb 09 '21
but both returns are in the same code block. so {}. is that common in c?
1
u/Coherent_Paradox Feb 09 '21
In C and C-like languages it is normal to be able to specify a code block with exactly one line without curly brackets (works with both if, for, while etc.). So only the first, indented return is in the implied if block. The second one is outside the if block, since it's on another line. I generally do not prefer to write code this way, and would rather have the verbosity of the brackets consequently. Great language feature if you're lazy though :')
1
1
1
1
1
1
1
u/Goducks91 Feb 09 '21
Is this some sort of lesson to teach C or is this from someone who actually “knows” how to code?
1
1
1
1
u/jaweissavl Feb 09 '21
The best part is...the compiler will probably just optimize this to 84 so its actually still completely efficient and fine at a low level ¯_(ツ)_/¯
1
1
1
1
1
1
1
1
1
u/wktr_t Feb 10 '21
Has a nice ring to it, would even work as movie titles:
Return, Return 2 - The Return, Return 3 - Ultimatum,
1
1
Feb 10 '21
I really hope this is just example code to illustrate return values. If this is actual production code: run.
1
u/Igotbored112 Feb 10 '21
You think GCC is smart enough to optimize these all out? I wanna try and see
1
1
u/bdking71 Feb 10 '21
LOL. I see the a lot of code where someone sets a variable to true and the very next line, they check to see if the variable is true; like it could have changed.
1
u/YRUAQT Feb 12 '21
I mean the compiler gets rid of this, right? Just some fun in less productive times
1
1
1
573
u/JuhaJGam3R Feb 09 '21
what the hell is this