News for hackers. Stuff that matters.
Re:C, what the fuck??! by threatripper on Sunday December 15, 2019 @07:20AM (#21795871)
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??! by stephen_g on Sunday December 15, 2019 @07:28AM (#21795894)
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??! by bowero on Sunday December 15, 2019 @07:27AM (#21795892)
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??! by threatripper on Sunday December 15, 2019 @08:03AM (#21796011)
So it would take some clueless developer who adds the compiler flags to get rid of the warnings during the yearly code cleanup season.

Therefore the probability of this happening by accident is 0 but the probability of this happening by incompetence (after the trigraph already slipped in undetected) hovers around 82%.

Re:C, what the fuck??! by bowero on Sunday December 15, 2019 @08:55AM (#21796218)
Sadly, you might have a very good point here.
Re:C, what the fuck??! by pksadiq on Sunday December 15, 2019 @07:24AM (#21795880)
> 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??! by hvdijk on Sunday December 15, 2019 @07:31AM (#21795904)
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.

Re:C, what the fuck??! by threatripper on Sunday December 15, 2019 @07:56AM (#21795993)
Did I really produce a Scotsman there? I would break it down like this:

* Professionals want to appear professional to the people who pay them.

* People who read the code can have an influence on the people who select which professional gets hired. (At least negatively if they find examples of poor practices.)

* Professionals therefore avoid any behavior that would be interpreted as unprofessional.

* Multiple question marks appear unprofessional and are therefore avoided. (Or would you concur???)

* I could not find a counterexample in my memory.

If this can be interpreted in a "no true Scotsman" way then it would be: "All Scotsmen who showed the behavior have been denied the citizenship." and then in turn they really wouldn't be true Scotsmen anymore because they lost the citizenship.

Re:C, what the fuck??! by hvdijk on Sunday December 15, 2019 @08:23AM (#21796098)
I think that last point illustrates the problem: you base your idea of "professional" on the professionals you have worked with or whose code you have read, who might not write such things. At the same time, in code I have read, I have seen it in ways that did not look out of place to me. What that tells me is that this is not a professional vs. unprofessional thing, it is just different programming norms. It is similar to how I think we can agree that neither tabs nor spaces are unprofessional, but insisting on either in a codebase already written using the other style is.
Re:C, what the fuck??! by detaro on Sunday December 15, 2019 @04:29PM (#21799118)
> Multiple question marks appear unprofessional and are therefore avoided.

Seems like a really weak assumption to me. Seen enough swear words etc in actual code bases, "???" in bug trackers, ... to think people would worry about the number of "?" they use in comments.

Re:C, what the fuck??! by faissaloo on Monday December 16, 2019 @09:00AM (#21802997)
Please refrain from misusing fallacies.
Re:C, what the fuck??! by spacemanmatt on Monday December 16, 2019 @07:41AM (#21802589)
Pro dev here. I am working on a codebase that is large and juvenile. The original authors didn't know about functions or something; it's pure spaghetti PHP.

I definitely add comments with tons of questions and potential trigraphs when I use punctuation in lieu of actual cursing. Don't get me wrong. I curse a lot in comments, too.

TL/DR: bad code -> angry comments

Re:C, what the fuck??! by JohnL4 on Monday December 16, 2019 @08:39AM (#21802891)
Similar here. Deepest sympathies.

However: https://www.jetbrains.com/help/phpstorm/refactoring-source-c... ?