[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
ITT: we abuse language specifications as flagrantly as possible
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 40
Thread images: 4
File: SittingDog.jpg (112 KB, 450x384) Image search: [Google]
SittingDog.jpg
112 KB, 450x384
ITT: we abuse language specifications as flagrantly as possible without generating compile errors.

int main() {
int a=sizeof(sizeof(a++));
}
>>
>>55001551
How exactly is this abuse? It's a retarded piece of code, but it'll work.
>>
Does a = 4? Please be right
>>
>>55001583
You're using a while defining it.
>>
>>55001764
system-dependent
>>
>>55001551
int i = 5;
i = ++i + ++i;
>>
File: facepalm, despair.jpg (26 KB, 400x281) Image search: [Google]
facepalm, despair.jpg
26 KB, 400x281
>>55001551
>>55002019
WTF. Why does this work?
>>
>>55002200
getting 14 as C, 13 as C++.
>>
>>55002200
Nice quad dubs btw, senpai.
>>
>>55002831
Are you using the same compiler?
>>
>>55002258
why shouldn't it?
>>
>>55002871
Yeah, I didn't think about that. Was using an online compiler to quickly test it.

https://ideone.com/siiVoU
https://ideone.com/UdC7XO
>>
>>55002831

So I guess the C compiler is treating it as

i = ++i++ + i
>>
>>55001551
>opening brace on same line as function signature
>no space on either side of assignment operator

Disgusting.
>>
File: 1461394868042.jpg (37 KB, 210x263) Image search: [Google]
1461394868042.jpg
37 KB, 210x263
>>55003398
Aye. OP is a faggot.
>>
>>55002896
Because a is referenced before it's declared.
>>
File: image_0.jpg (49 KB, 575x575) Image search: [Google]
image_0.jpg
49 KB, 575x575
>>55002200
>>
canPooInLoo :: Person -> Bool
canPooInLoo = canPooInLoo
>>
>>55002258
because sizeof doesn't* evaluate its argument.

*usually
>>
>>55001764
a = sizeof(size_t).

it's 8 on my system.
>>
Didn't come up with it myself, but:

#include <iostream>
#define System S s;s
#define public
#define static
#define void int
#define main(x) main()
struct F{void println(char* s){std::cout << s << std::endl;}};
struct S{F out;};

public static void main(String[] args) {
System.out.println("Hello World!");
}
>>
>>55004209
No. You're confusing two planes of existence (in the absence of optimizing away compile time constants, anyway): compile time and run time.
>>
>>55005133
heh, nice one
>>
js time

myFunction();

// code here can use carName
document.getElementById("main").innerHTML = "I can display " + carName;

function myFunction() {
carName = "Volvo";
}
>>
>>55005133

You sir, I like you.
>>
>>55002019
Which doesn't matter because sizeof doesn't need the value of a, only what kind of variable it is. Then in this example it'll sizeof the return type of sizeof, effectively nullifying whatever a has to do with it. All I'm unsure of is whether it'll increment a after the outermost sizeof, adding 1 to the return value of the outermost sizeof, or whether it's completely nullified.
>>
I posted this somewhere once and it triggered so, so many people.

int main() {
for(int i; (i = getchar()) != EOF; printf("%d ", i));
}
>>
>>55006839
Triggered.
>>
>>55003398
>>personal preference
>>personal preference
>
>Disgusting.
>>
int main(){for(;;);}
>>
>>55008326
I don't see how this is abuse. It's the equivalent of a "program" made in assembly just being NOP.
>>
>>55005133
%:define Begin <%
%:define End %>
%:define If if (
%:define Then )
%:define Equals =
%:define Print std::cout <<
%:define Integer int
%:define Double double
%:define String string
%:define Character char
%:define Boolean bool
%:define Single float
%:define Long long
%:define Byte unsigned char
%:define Void void
%:define Object class
%:define EndObject };
%:define Structure struct
%:define Nothing NULL
%:define NoArguments ()
%:define Is ==
%:define Public public:
%:define Private private:
%:define Application int main(int argc, char* argv[])
%:define Method void
%:define Read std::cin >>
%:define Not !
%:define IsNot !=
%:define For for(
%:define While while(
%:define Do )
%:define Less <
%:define Greater >
%:define Increment ++
%:define HaltAndCatchFire for(;;) fork();
%:define Split fork();
%:define Or ||
%:define And &&
%:define BitwiseAnd &
%:define BitwiseOr |
>>
>>55009852
That's just autism.
>>
send(to, from, count)
register short *to, *from;
register count;
{
register n = (count + 7) / 8;
switch (count % 8) {
case 0: do { *to = *from++;
case 7: *to = *from++;
case 6: *to = *from++;
case 5: *to = *from++;
case 4: *to = *from++;
case 3: *to = *from++;
case 2: *to = *from++;
case 1: *to = *from++;
} while (--n > 0);
}
}
>>
>>55009798
No it's not, it's an infinite loop not a NOP you moron
>>
>>55011702
No one is triggered by that because it's legitimate.
>>
>>55009852
you got some big syntax sugar
>>
>>55012254
infinite loops arent abuse
>>
>>55012254
But it's not. That's the equivalent of putting while(). It will never evaluate as true so it will never loop.
>>
>>55009852

>%:define HaltAndCatchFire for(;;) fork();

lel
Thread replies: 40
Thread images: 4

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.