https://bugs.llvm.org/show_bug.cgi?id=45779

            Bug ID: 45779
           Summary: Fold expression using comma gives unnecessary warning
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++17
          Assignee: unassignedclangb...@nondot.org
          Reporter: pk...@outlook.com
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

Created attachment 23435
  --> https://bugs.llvm.org/attachment.cgi?id=23435&action=edit
The file containing the code described.

Compiling the attached C++17 file (code also below) produces two warnings,
indicating that the result of the fold expression is unused. The result is
used.

template <typename ...Ts>
auto last(Ts ...xs) { return (xs , ...); }

int main(int argc, char *argv[])
{
  int a = 0, b = 1, c = 2;
  return last(a,b,c);
}

The warning messages are:

clang++  -std=c++17 comma-fold.cpp 
comma-fold.cpp:2:31: warning: expression result unused [-Wunused-value]
auto last(Ts ...xs) { return (xs , ...); }
                              ^~
comma-fold.cpp:7:10: note: in instantiation of function template specialization
'last<int, int, int>' requested here
  return last(a,b,c);
         ^
comma-fold.cpp:2:31: warning: expression result unused [-Wunused-value]
auto last(Ts ...xs) { return (xs , ...); }
                              ^~
2 warnings generated.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to