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

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 21 09:23:23 PDT 2023


erichkeane added a comment.

In D148925#4287497 <https://reviews.llvm.org/D148925#4287497>, @tbaeder wrote:

> In D148925#4287218 <https://reviews.llvm.org/D148925#4287218>, @erichkeane wrote:
>
>> So things cast to 'void' can have side effects, right?  Does the call to discard still evaluate them?
>>
>> https://godbolt.org/z/a3ej9bxKe
>
> Yes. `discard(E)` is just `visit(E)`, except that it sets `DiscardResult` to `true` for that one level of visiting. Following `visit()` calls will have `DiscardResult = false` again.

Cool!  Mind adding the tests I proposed?  it would be nice to ensure/show side-effects are guaranteed.


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

https://reviews.llvm.org/D148925



More information about the cfe-commits mailing list