Skip to content

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