This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fix result-type and value_type computation in <valarray>.
ClosedPublic

Authored by Quuxplusone on May 31 2021, 9:30 AM.

Details

Summary

This came out of my comment on D103371...

The `operator[]` of `_UnaryOp` and `_BinaryOp` returns the result of
calling `__op_`, so its return type should be `__result_type`, not
e.g. `_A0::value_type`. However, `_UnaryOp::value_type` also should
never have been `_A0::value_type`; it needs to be the correct type
for the result of the unary op, e.g. `bool` when the op is `logical_not`.

This turns out to matter when multiple operators are nested, e.g.
`+(v == v)` needs to have a `value_type` of `bool`, not `int`,
even when `v` is of type `valarray<int>`.

Diff Detail

Event Timeline

Quuxplusone requested review of this revision.May 31 2021, 9:30 AM
Quuxplusone created this revision.
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald TranscriptMay 31 2021, 9:30 AM
ldionne accepted this revision.Jun 1 2021, 7:05 PM

I Discord'ed you about it, but let's talk about this here. I fail to see where the tests would fail if we still had the bug you're fixing. Please explain, but LGTM assuming there's an explanation :-). Thanks for correcting this long-standing issue with a not very glamorous type -- those corners are still important.

This revision is now accepted and ready to land.Jun 1 2021, 7:05 PM
This revision was landed with ongoing or failed builds.Jun 5 2021, 9:30 AM
This revision was automatically updated to reflect the committed changes.