6 ms·
Trigraphs make this obfuscated C submission possible: (https://gist.github.com/Property404/e31b99deb3527159e183 https://gist.github.com/Property404/e31b99deb352
by bradford 4y ago
Trigraphs make this obfuscated C submission possible: (https://gist.github.com/Property404/e31b99deb3527159e183 https://gist.github.com/Property404/e31b99deb3527159e183)
I've pasted it here for convenience (formatting fixed, thanks child comment!):
// Are you there god??/
??=define _(please, help)
??=define _____(i,m, v,e,r,y) r%:%:m
??=define ____ _____(a,f,r,a,i,d)
main(__)<%____(!_(-~-??-((-~-??-!__<<-
??-!!__)<<-??-(!!__<<!!__))+-~-~-??--~-~
-~-~-~-~-??-(-~-~-~-~-??-!!__<<-~!!__),-
??-!__))<%??>%>_(__,___)??<____
(printf("please let me die??/r%d bottle%s"
" of bee%s""""??/n",(!(___
%-~-~!!___))?--__+!___++:__+!___++,!(__-!!___)
&&___%-~-~!!___??!??!!(___%-~-~!!___??!??!__
-(-~!!___))?"":"s",___%-~-??-!!___<-??-!!___?
"r on the wall":"eeeeeeer! Take one down,pass ??/
it around")&&__&&_(__,___),"mercy I'm in pain")??<??>??>
- thamer 4y agoHow to format text on HN: https://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc For code blocks, prefix each line with two or more spaces.
- eek2121 4y agoThanks (I haven't seen this despite lurking on HN for 'a long time' and interacting with it recently, however, you clearly didn't quote the doc, which says Text after a blank line that is indented by two or more spaces is reproduced verbatim. (This is intended for code.) Small nitpick, however I am happy you linked the page.
- sargstuff 4y agoGuess with tri-graph elimination & awk getting unicode support will have to gawk C with cpp using pipology theory. But think the cpp has to go away first, after enough sed. https://grayson.sh/blogs/using-piphilology-to-hide-strings https://grayson.sh/blogs/using-piphilology-to-hide-strings https://www.gnu.org/software/gawk/manual/gawk.html#Signature https://www.gnu.org/software/gawk/manual/gawk.html#Signature...
- omoikane 4y agoRoughly the only good use of trigraphs these days is for obfuscated code, for example here: https://www.ioccc.org/years.html#1990_scjones https://www.ioccc.org/years.html#1990_scjones But trigraphs have gotten old even for IOCCC. In the guidelines for recent years, they specifically mention "We tend to dislike programs that ... obfuscate by excessive use of ANSI tri-graphs": https://www.ioccc.org/2020/guidelines.txt https://www.ioccc.org/2020/guidelines.txt
- lifthrasiir 4y agoNote that this uses not only trigraphs but also digraphs (here `<%`, `%>` and `%:`), which are similar to trigraphs in intended usages but behave much differently to digraphs in that it is a proper token and not a preprocessor substitution pattern. `printf("??(foo??)<:bar:>%c", "quux"<:1:>)` prints `[foo]<:bar:>u`, for example. Therefore digraphs are deemed less dangerous (however obscure) than trigraphs and do not require any compiler options.
- DonHopkins 4y agoBjarne Stroustrup proposed Generalized Overloading for C++2000, which not only lets you override all kinds of white space, like between two symbols separated left to right by a space (i.e. "a b" to add a to b), or two symbols separated top to bottom by a newline (i.e. "a \n b" to divide a by b, like a fraction), or even by tabs, or either kind of comment, but it also lets you override writing two symbols next to each other without any separation (i.e. "ab" to multiply a by b, which mathematicians love)! Of course they also had to limit the number of characters per symbol to 1 in order to unambiguously support the "ab" syntax for multiplying a and b (or however you wanted to overload the "absence of white space" operator), but fortunately they mitigated that little problem by making C++ fully supports Unicode, so you had thousands of single character Unicode variable names to choose from. His prophetic intuition was spot-on, now that there are so many expressive and inclusive Emoji characters to use for single character variable names! https://www.stroustrup.com/whitespace98.pdf https://www.stroustrup.com/whitespace98.pdf I really appreciate Bjarne Stroustrup's clean simple design and coherent long term vision for C++2000, and I'm looking forward to using three dimensional white space overloading in C++3D.
- ralphb 4y agoI am almost unhappy to learn that this was a joke. Would have been nice to put a final (personal) nail in the C++ coffin with this insanity. However, I guess it says enough that I did have to dig quite far into the paper to realize whether Bjarne was joking or not.
- gpderetta 4y agoWe do not have yet three dimensional white space overloading unfortunately, will have to wait for the next release train, targeting C++26. In the meantime, you can use multidimensional analog literals: http://www.eelis.net/C++/analogliterals.xhtml http://www.eelis.net/C++/analogliterals.xhtml