LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 38282 - expected ';' after expression
Summary: expected ';' after expression
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: PC Linux
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-23 19:00 PDT by Hao Zhong
Modified: 2018-07-27 14:57 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hao Zhong 2018-07-23 19:00:56 PDT
My command line is clang++ -std=c++17 code0.cpp

The code is as follow:

template<typename... Args>
void spurious(Args... args)
{
    (... + args).member;
}

int main()
{
}

The error message is:

code0.cpp:4:14: error: expected ';' after expression
 (... + args).member;
             ^
             ;
code0.cpp:4:14: error: expected expression
2 errors generated.

Another similar code sample is as follow:

template <typename... Args>
int
foo (Args... args)
{
 return (... + args).member;
}

struct S { int member; } s = { 0 };

int
main ()
{
 return foo (s);
}

Again, clang++ rejects it, but g++ accept it.

Are the above two code samples legal code?
Comment 1 Nicolas Lesser 2018-07-27 14:57:19 PDT
Yes they are, as a fold-expression is a primary-expression.

Thanks! This is fixed in r338170.