Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wsign-conversion #18

Open
oschonrock opened this issue Oct 3, 2021 · 5 comments
Open

-Wsign-conversion #18

oschonrock opened this issue Oct 3, 2021 · 5 comments

Comments

@oschonrock
Copy link

oschonrock commented Oct 3, 2021

/home/oliver/c/qa/include/sha1/sha1.hpp:240:20: warning: implicit conversion changes
      signedness: 'int' to 'uint32_t' (aka 'unsigned int') [-Wsign-conversion]
                   | (buffer[4*i+0] & 0xff)<<24;
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/oliver/c/qa/include/sha1/sha1.hpp:263:35: warning: implicit conversion changes
      signedness: 'unsigned long' to 'std::streamsize' (aka 'long') [-Wsign-conversion]
        is.read(sbuf, BLOCK_BYTES - buffer.size());
           ~~~~       ~~~~~~~~~~~~^~~~~~~~~~~~~~~
@vog
Copy link
Owner

vog commented Oct 4, 2021

Please provide some context to your report. Which OS, architecture and compiler version do you use?

@oschonrock
Copy link
Author

oschonrock commented Oct 4, 2021

Sorry. Here you go:

OS: ubuntu 20.04 - arch x86_64
compiler: clang-12

compile command:

clang++  -Wall -Wextra -Wpedantic -Wconversion -Wshadow -Wextra-semi -Wshadow-field-in-constructor -Wmissing-noreturn -Wunreachable-code-break -std=c++2a

I believe it is the -Wconversion which is throwing this warning.

@matu3ba
Copy link

matu3ba commented Nov 27, 2024

here are my fixes with -Weverything for a job interview task
https://gist.github.com/matu3ba/930715a9cb1e361ed8e03118a60970e4

Compile with .hpp included with

clang++ -std=c++20 -Werror -Weverything  -ferror-limit=100 -Wno-c++98-compat-pedantic -Wno-unsafe-buffer-usage -Wno-switch-default ./example.cpp -o example.exe
zig c++ --target=x86_64-windows -std=c++20 -Werror -Weverything  -ferror-limit=100 -Wno-c++98-compat-pedantic -Wno-unsafe-buffer-usage -Wno-switch-default ./example.cpp -o example/.exe

clang version 18.1.8
zig version 0.14.0-dev.6403+e2f24a2d7

@vog
Copy link
Owner

vog commented Nov 28, 2024

@matu3ba This is great! Would you mind creating a pull request?

@matu3ba
Copy link

matu3ba commented Dec 6, 2024

see #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants