-
Notifications
You must be signed in to change notification settings - Fork 265
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Clang produces a Wshorten-64-to-32 warning with a cpp2::range when it is initialised with an integer literal as the first member and an expression producing a size_t/size_type as the second member.
To Reproduce
Run cppfront on the following code and then compile with clang with -Wconversion:
main: () = {
v: std::vector = (11, 22, 33);
for 0 ..< v.size() do (i) { // Warning
v[i]++;
}
std::println("v: {}", v);
for 0uz ..< v.size() do (i) { // No warning with `uz`
v[i]++;
}
std::println("v: {}", v);
}The warning is:
warning: implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'const std::type_identity_t<int>' (aka 'const int') [-Wshorten-64-to-32]
Repro on Godbolt
This is because the cpp2::range constructor deduces the type from only the first parameter:
range(
T const& f,
std::type_identity_t<T> const& l,
bool include_last = false
)Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working