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

Fixed key lengths in benchmark and linked math library #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Stemt
Copy link

@Stemt Stemt commented Jan 4, 2025

When trying to build the benchmarks I found that the compiler generated the following error:

/home/ar/sources/hashmap.h/bench/sse42.c:50:50: error: ‘snprintf’ output truncated before the last format character [-Werror=format-truncation=]
   50 |     snprintf(keys + (i * key_len), key_len, "%08x", i);
      |                                                  ^
/home/ar/sources/hashmap.h/bench/sse42.c:50:5: note: ‘snprintf’ output 9 bytes into a destination of size 8
   50 |     snprintf(keys + (i * key_len), key_len, "%08x", i);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

I fixed this by adding space for the null terminator by increasing every key_len by 1.

I also found undefined references to 'sqrt' on my linux machine so I added a check that links the math library if it is available.

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

Successfully merging this pull request may close these issues.

1 participant