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

C++17 if-with-initializer doesn't compile with empty init-statement #34729

Closed
llvmbot opened this issue Nov 22, 2017 · 1 comment
Closed

C++17 if-with-initializer doesn't compile with empty init-statement #34729

llvmbot opened this issue Nov 22, 2017 · 1 comment
Labels
bugzilla Issues migrated from bugzilla c++17

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 22, 2017

Bugzilla Link 35381
Resolution FIXED
Resolved on Apr 13, 2018 14:25
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @lichray
Fixed by commit(s) r327782

Extended Description

Overview:
An if-with-initializer with an empty init-statement followed by a semicolon is valid in C++17, but rejected by clang (trunk).

Steps to reproduce:
Compile this code:

int main()
{
if (; true);
}

Actual Results:
The following errors are shown:

3 : :3:6: error: expected expression
if (; true);
^
3 : :3:12: error: extraneous ')' before ';'
if (; true);
^

Expected results:
The code should compile.

Additional information:
According to the C++17 grammar, the init-statement in an if-with-initializer is allowed to be an empty expression followed by a semicolon.

GCC 7.2 and MSVC 19 2017 both accept this code.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 13, 2018

This was fixed some time ago, thanks! :)

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++17
Projects
None yet
Development

No branches or pull requests

1 participant