Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lex.phases] Clarify the state of forming logical-lines when partially composing a comment #6854

Closed
ContingencyOfTautologicalContradictions opened this issue Mar 10, 2024 · 5 comments

Comments

@ContingencyOfTautologicalContradictions
Copy link

int meow/\
/ a single-line comment
;

Clang says that this is ok, GCC doesn't.

I think Clang here is right because the standard doesn't mention that you can't form a new logical-line while the comment is partially composed. In fact, forming logical lines (phase 2) should happen before processing comments (phase 3). So the comment should be in a single.line when the compiler "see" it at the phase 3.

I think clarifying whether this is allowed or not, preferably at the phase 3, would be a nice addon.

@jensmaurer
Copy link
Member

I think [lex.phases] is very clear here: Line splicing happens in phase 2, before recognizing comments in phase 3. I don't know what needs to be clarified in addition to that

Please post a bug report to gcc.

@jwakely
Copy link
Member

jwakely commented Mar 10, 2024

Clang says that this is ok, GCC doesn't.

GCC compiles the code.

@ContingencyOfTautologicalContradictions

Clang says that this is ok, GCC doesn't.

GCC compiles the code.

Not when -Werror=comment, see https://godbolt.org/z/fjrfn8sqc

@jensmaurer jensmaurer closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2024
@jwakely
Copy link
Member

jwakely commented Mar 10, 2024

That's just a warning telling you the comment is split across two lines, it doesn't mean GCC thinks the code is invalid. If you ask for warnings to be turned into errors, that's what you get. It doesn't mean GCC doesn't accept the code. It certainly doesn't mean there's anything wrong with the standard.

If you don't want an error there, don't use -Werror=comment, it's quite simple.

@jensmaurer
Copy link
Member

And I think gcc is right to give you the warning, because writing such line-spliced comments might, in fact, be a source of confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants