Note: This suggestion comes out of some discussion in the comment thread on this question.
Many times in recent months, I have noticed questions about C++ code which are tagged ambiguously as C/C++ questions, and make no mention of compiler or standard -- then an argument ensues among the various folks who provide answers to such questions about how best to proceed.
My experience has been that, oftentimes, the code is obviously not C for reason of including C++ headers or something, and so the C tag can be ignored. Or, it seems like the question really has nothing to do with C++ and so the C++ tag is ignored. Occasionally it happens that people decide to retag it just as C / C++ (example) and there are earlier meta threads about that issue.
This thread is about a different but related issue -- when a question is tagged only as C++, and there is no mention of a compiler or standard, how should we answer?
My experience / impression had been that usually, you assume at least C++98 standard, maybe C++11 -- if it makes a difference you can describe the difference in the answer. For instance that was the basis I gave for this answer which people seemed to like. Note that, the question is extremely difficult if not impossible to answer if you don't assume some standard -- OP asks whether behavior in some situation is defined or not.
In the linked question (from today, here's the link again), OP posts some code which variously could be C or C++, and uses a gcc
-specific extension function. Then he asks if it is "legitimate".
Argument ensues about whether "legitimate" means standards-compliant, and if not, what else it could mean / what could be the basis of answering the question.
In this case, the question got retagged to add the gcc
tag and then answered on that basis.
From the exchange in the comments, my impression now is that the [c++] tag is actually extremely broad, much broader than I had thought. Especially, from the up-voted answer in this meta-question
If someone tags a question as C++, then they are intending to write and compile C++ code. Even if the code is horrible, and they have likely compiled it using a copy of UnicornsC++Compiler that does not follow the standard of C++, they still want an answer that makes it work in C++.
If the C++ tag is meant to encompass also these questions that aren't about "standard" C++, then a lot of questions become ambiguous / hard to answer, and a lot of questions end up accumulating a lot of comment wars between answerers about what is an acceptable basis for an answer.
In many cases, if the question is easy / basic, it doesn't really matter what standard or compiler they target.
But in other cases, if you can't assume some kind of standards-conforming compiler is being used, or, you might be supposed to answer assuming any compiler, this makes what would be an easy question very broad and requires expertise that many fewer people have -- most people don't necessarily have a lot of experience with more than a few compilers, and there are a lot out there.
In the comment thread on this most recent question, @Karoly Horvath writes:
@ChrisBeck: No idea. I just use common sense. Novice users have no idea about these issues, and should be informed gently. – Karoly Horvath 51 mins ago
I think that is right, it usually isn't that hard to figure out what to do. However, what I'm suggesting is that we should try harder to make people not just use the [c++] tag, but also to specify one or several standard tags, or specify a compiler tag, and aggressively retag questions as it becomes clear.
- It makes it alot easier for people who are browsing questions / looking for useful info if the standard / compiler being discussed is clearly tagged and they don't themselves have to do the common-sense deduction while browsing around. This makes SO a more useful resource for everyone.
- It avoids these common and unsightly threads of comments where OP may mostly not participate and a bunch of C++ gurus go back and forth about what is a reasonable basis for answering the question.
Further, what I think we should do is edit the tag wiki for [c++] so that it clarifies the meaning of the tag. Currently it reads:
C++ is a general-purpose programming language based on C. Use this tag for questions about code (to be) compiled with a C++ compiler.
I think it should includes at the end a sentence along the lines:
Questions tagged only as [c++] are not assumed to be about code conforming to any particular standard -- for this reason, many questions are too broad to answer unless you also specify one or several standards / compilers. Please consider adding tags like [c++11], [gcc], [msvc], etc.
Alternatively, I guess we could decide that SO is more useful as a resource if we assume they are using some standard-conforming compiler unless they specifically say otherwise -- don't consider possibility of UnicornC++ unless they mention it. But regardless I think it would be better if we decide this on meta and then say it clearly in the tag wiki entry. For most other programming language tags on SO I guess there isn't this issue of "what if they are using a non-conforming implementation", it's always assumed that javascript answers follow some ECMAScript standard, etc. So if the C++ tag works differently it is probably worth documenting that somewhere.