[PATCH] D148925: Fix discarding void-typed comma expressions

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 21 07:54:42 PDT 2023


erichkeane added a comment.

So things cast to 'void' can have side effects, right?  Does the call to discard still evaluate them?

https://godbolt.org/z/a3ej9bxKe

  constexpr int foo(int start) {
      int i = start;
  
      (void)i++;
      (void)i++,(void)i++;
      return i;
  }
  constexpr int Value = foo(5);
  static_assert(Value == 8);


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148925/new/

https://reviews.llvm.org/D148925



More information about the cfe-commits mailing list