Forum: Offtopic Main is usually a function. So then when is it not?


von Kaj G. (Firma: RUB) (bloody)


Lesenswert?

Ich finde es immer wieder interessant, auf was fuer Ideen Menschen so 
kommen :)

Main is usually a function. So then when is it not?
http://jroweboy.github.io/c/asm/2015/01/26/when-is-main-not-a-function.html
1
It began when my coworker, despite already knowing how to program,
2
was forced to take the intro level Computer Science course at my
3
university. We joked with him about how he needs to make a program
4
that works, but the grading TAs wouldn’t be able to figure out how
5
it works. So that is the requirement, to make a functioning program
6
that completes an assignment while obfuscating it such that the
7
graders think that it shouldn’t work.
8
9
[...]

von mh (Gast)


Lesenswert?

Interessante Idee, aber  ... was sagt der Standard dazu?
1
The behavior is undefined in the following circumstances:
2
...
3
-A program in a hosted environment does not define a function named main using one of the specified forms (5.1.2.2.1).
4
...
Es ist also nicht nur abhängig von der konkreten CPU, es ist auch klar 
UB.
1
"I’m guessing all that will happen when my coworker turns in an assignment looking like this is they will take off points for bad coding style and say nothing else about it."
Oder es gibt 0 Punkte, weil das Program nicht funktioniert.

von Jörg W. (dl8dtl) (Moderator) Benutzerseite


Lesenswert?

Naja, der IOCCC ist ja nun schon lange erfunden. Da könnte sich der
Student ja genügend Anregungen holen, wie man ein Programm so weit
"obfuscated" abfassen kann, dass trotz Konformität zum Standard keiner
mehr weiß, warum es denn funktioniert …

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.