Bug 24278 – std.math.abs promotes unsigned argument to 32 bits

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-12-12T15:43:09Z
Last change time
2023-12-15T08:48:48Z
Keywords
pull
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2023-12-12T15:43:09Z
```D import std.math; void main() { assert(is(typeof(abs(ubyte(8u))) == ubyte)); } ``` The assert fails, while the documentation says "the return type will be the same as the input."
Comment #1 by dlang-bot — 2023-12-15T00:48:37Z
@HuskyNator updated dlang/phobos pull request #8861 "Update math.algebraic.d#abs to return correct integral type" fixing this issue: - Fix misplaced doc backticks and reorder attributes Reorder attributes as per style guidelines: > Attributes should be listed in alphabetical ordering Fix issue 24278 https://github.com/dlang/phobos/pull/8861
Comment #2 by dlang-bot — 2023-12-15T08:48:48Z
dlang/phobos pull request #8861 "Update math.algebraic.d#abs to return correct integral type" was merged into master: - e5e6f6088d3967e548cbb59a5b72f1db3b61b4bc by HuskyNator: Fix misplaced doc backticks and reorder attributes Reorder attributes as per style guidelines: > Attributes should be listed in alphabetical ordering Fix issue 24278 https://github.com/dlang/phobos/pull/8861