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

Sanitizer detects a potential null deference [gcc] #52

Open
g-berthiaume opened this issue Jan 14, 2025 · 0 comments
Open

Sanitizer detects a potential null deference [gcc] #52

g-berthiaume opened this issue Jan 14, 2025 · 0 comments

Comments

@g-berthiaume
Copy link

When compiled with the -fsanitizer flag, gcc 13.2.0 warns about a NULL deference in tau.

tau/tau/tau.h:1324:61: warning: dereference of NULL '0' [CWE-476] [-Wanalyzer-null-dereference]
 1324 |             tauStatsFailedTestSuites[failed_testcase_index] = i; 
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~  

Step to reproduce: compile the following with gcc -fsanitizer main.c -o main

// main.c
#include "tau/tau.h"

TAU_MAIN() // sets up Tau (+ main function)

TEST(foo, bar1)
{
    int a = 42;
    int b = 13;
    CHECK_GE(a, b); // pass :)
    CHECK_LE(b, 8); // fail - Test suite not aborted
}

TEST(foo, bar2)
{
    char *a = "foo";
    char *b = "foobar";
    REQUIRE_STREQ(a, a); // pass :)
    REQUIRE_STREQ(a, b); // fail - Test suite aborted
}

--

This library is great. It strikes a good balance between simplicity and functionality.
Thanks for your work!

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

1 participant