Closed
Description
Describe the bug
warning: implicit conversion changes signedness: 'int' to 'size_type' (aka 'unsigned long')
To Reproduce
Steps to reproduce the behavior:
- Sample code - distilled down to minimal essentials please
https://cpp2.godbolt.org/z/Wh7jTczzh
main: () = {
v: std::vector = ( 1, 2, 3, 4, 5 );
v[6] = 0;
}
Can avoid the warning by using v[6u]
.
-
Command lines including which C++ compiler you are using
-std=c++23 -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -Werror=unused-value -
Expected result - what you expected to happen
Clean compile, and out of bounds access error when executed.
- Actual result/error
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:467:30: warning: implicit conversion changes signedness: 'int' to 'size_type' (aka 'unsigned long') [-Wsign-conversion]
467 | return CPP2_FORWARD(x) [ CPP2_FORWARD(arg) ];
| ~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:271:37: note: expanded from macro 'CPP2_FORWARD'
271 | #define CPP2_FORWARD(x) std::forward<decltype(x)>(x)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
build/main.cpp:19:11: note: in instantiation of function template specialization 'cpp2::assert_in_bounds<std::vector<int>, int>' requested here
19 | cpp2::assert_in_bounds(std::move(v), 6) = 0;
| ^
1 warning generated.
Additional context
Investigating #798 File name and line number when the application terminates