Comments (5)
I suggest we simply un-publish this question. It was created pre-C++17 when trigraphs were still a thing. Then it got ported to C++17 with the rest of the questions on the site, but I think it should have been unpublished instead since it no longer makes much sense. Any objections?
from cppquiz.
That's neat, and I'm happy to know about it, but here's the thought process I went through (which I'd think is the same for most users):
- I really really hope that this is 1.
- But it couldn't possibly be 1. I mean, why would they ask?
- There's this unusual comment, but it's just a comment.
- Even the syntax highlighter agrees, that's just a comment
- Well I give up, I'm entering 1.
- So I'm right that this is 1.
- And I'm right that that was just a comment.
- So what I have learned was that there used to be a trigraph called
??/
, but I don't know what it does and it's not actually relevant to the question I just answered.
Can you see why, coming at it from that perspective, the question just comes across as very strange?
I think what it comes down to is, if you knew what this trigraph was and what it did then this question is about "did you know this was removed in C++17". But if you don't (which I think is pretty common, given that it was removed), the question is "can you read code", and the answer description says "there's also a thing here which does nothing and is ignored".
Perhaps the solution is to add something like this to the explanation:
Prior to C++17, the
??/
was parsed by the preprocessor as being equivalent to the character\
. Thus, the next line withx = 1;
would have been treated as part of a multiline comment rather than as executable code. Therefore the output would have been0
in older versions of the standard.
You can reenable this behavior in GCC using the-trigraphs
option, or by specifying-std=c++14
.
In addition, this is marked as level 3 difficulty. Makes it more confusing, since unless you know a piece of esotera this appears to be one of the most straightforward programs one could possibly write.
from cppquiz.
Please look at the compiler explorer link given in the answer. You can add the -trigraphs
option to see the difference (it will compile, but the result will be different).
from cppquiz.
I agree that we should expand the explanation. @knatten take a look please
from cppquiz.
The question has now been retracted: https://cppquiz.org/quiz/question/147
from cppquiz.
Related Issues (20)
- Compiler Explorer's link in 339 uses -lpthread instead of -pthread HOT 3
- Stylistic issues in the code of 144 HOT 1
- Port the questions to C++23 HOT 11
- CI runs twice on PRs from the same repo HOT 5
- Use a proper software license
- Question #231 HOT 4
- Question #127 HOT 2
- Typo in Question №174 HOT 1
- Question 323 wrong result HOT 2
- Question 244 seems to have incorrect answer HOT 1
- English grammar issue in question №15 HOT 1
- Improvements to the answer of question №124 HOT 2
- Question #251 has a potentially unsafe link HOT 2
- Adding questions on C-language, as separate chapter HOT 1
- Strange formatting in question 323 HOT 2
- Support symbol '-' in standard_ref() HOT 5
- Support fenced code blocks in explanations HOT 1
- Stop using PickleSerializer
- Question #231 has compilation errors HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cppquiz.