Skip to content

Conversation

@bluetarpmedia
Copy link
Contributor

Use a CTAD deduction guide to deduce the std::common_type for both types (if a common one exists).

This allows code like the following to compile without integer precision conversion warnings:

for 0 ..< vector.size() do (e) { ... }

since the integer literal 0 and the size expression evaluate as different signed/unsigned types.

Also update the regression tests after recent changes.

Fixes #1269

Use a CTAD deduction guide to deduce the `std::common_type` for both types (if a common one exists).

This allows code like the following to compile without integer precision conversion warnings:
```
for 0 ..< vector.size() do (e) { ... }
```
since the integer literal 0 and the size expression evaluate as different signed/unsigned types.
@feature-engineer
Copy link

feature-engineer commented Sep 19, 2024

Does putting e - 1 < 0 inside the loop still fails to compile (as it should)?
What about vector[e - 1] when e is zero?
Or when we iterate backwards?

@hsutter
Copy link
Owner

hsutter commented Sep 23, 2024

Thanks!

@feature-engineer AFAICS this only affects ..< and ..= expressions so those would be unchanged.

@hsutter hsutter merged commit ce033fe into hsutter:main Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Wshorten-64-to-32 clang warning when using range 0 ..< vector.size()

3 participants