Live data from Hacker News

C, what the fuck??!

bowero.nl

1–10 of 38 posts

Re: C, what the fuck??!

#2
What is the probability of something like this appearing in a normal program written by somebody who is unaware of trigraphs?

I am also not aware of any professional who would use multiple question marks in any kind of serious code that could be read by anybody else because that kind would reflect negatively on the perception of his professionalism.

Re: C, what the fuck??!

#4

What is the probability of something like this appearing in a normal program written by somebody who is unaware of trigraphs? I am also not aware of any professional who would use multiple question marks in any kind of serious code that could be read by anybody else because that kind would reflect negatively on the perception of his professionalism.

> What is the probability of something like this appearing in a normal program written by somebody who is unaware of trigraphs?

A good compiler (eg: gcc) will warn if any token is interpreted as a trigraph

Edit: digraph works a bit differently [0]

[0] https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C

Re: C, what the fuck??!

#5
This is about that ancient EBCDIC (IBM's ASCII "competitor") specific hack called trigraphs, which in modern compilers are opt-in anyhow: "To understand this, I have to admit one thing: I have to pass -trigraphs to a modern version of gcc before this actually works. "

C++17 actually removed support for these.

Re: C, what the fuck??!

#6

What is the probability of something like this appearing in a normal program written by somebody who is unaware of trigraphs? I am also not aware of any professional who would use multiple question marks in any kind of serious code that could be read by anybody else because that kind would reflect negatively on the perception of his professionalism.

The chance of this accidentally happening is almost 0. This is what `gcc` does:

`test.c:6:31: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]`

Re: C, what the fuck??!

#7

What is the probability of something like this appearing in a normal program written by somebody who is unaware of trigraphs? I am also not aware of any professional who would use multiple question marks in any kind of serious code that could be read by anybody else because that kind would reflect negatively on the perception of his professionalism.

The article mentions that they had to explicitly enable it with a compiler flag to get it to work. I doubt any modern compiler would still support these by default.

Re: C, what the fuck??!

#8
Seriously, at this point C should be considered dangerous and should be actively discouraged. I would even go so far as to legislate it. We can't have this sort of thing in 2019.

Re: C, what the fuck??!

#9
Digraphs were supposed to be a easier-to-read alternative to trigraphs. Unfortunately, the extended list of digraphs with many additional logic operators by C++ never entered C, i.e.

    %:%:    ##
    compl   ~
    not     !
    bitand  &
    bitor   |
    and     &&
    or      ||
    xor     ^
    and_eq  &=
    or_eq   |=
    xor_eq  ^=
    not_eq  !=
C only has basic ones (still more intuitive than trigraphs).

      ]
      }
    %:  #
Last time, I had to type a C program on a touchscreen, and those symbols were extremely difficult to enter. I knew digraphs can help, but then realized that I couldn't use the digraphs for logic operators without programming C under C++.

Re: C, what the fuck??!

#10

What is the probability of something like this appearing in a normal program written by somebody who is unaware of trigraphs? I am also not aware of any professional who would use multiple question marks in any kind of serious code that could be read by anybody else because that kind would reflect negatively on the perception of his professionalism.

Nice "No true Scotsman" logic there. Sure, if you see multiple question marks as an indicator of unprofessionalism, then by definition, no professional would use that. At the same time, your definition of professional is not one that is useful in any other context.

In code written by people whose job it is, in part, to write code, i.e. what I would call professionals, multiple question marks do sometimes occur.

Post reply on HN