Skip to content

Commit

Permalink
Add support for InvalidFunctionArg lgamma() (danmar#5845)
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitcowboy committed Jan 5, 2024
1 parent fde7ea6 commit 32cabec
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<not-uninit/>
</arg>
</function>
<!-- https://cplusplus.com/reference/cmath/lgamma/ -->
<!-- double lgamma(double x); -->
<function name="lgamma,std::lgamma">
<use-retval/>
Expand All @@ -3044,8 +3045,11 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
<valid>!0.0:</valid>
</arg>
</function>
<!-- https://cplusplus.com/reference/cmath/lgamma/ -->
<!-- float lgammaf(float x); -->
<function name="lgammaf,std::lgammaf">
<use-retval/>
Expand All @@ -3055,8 +3059,11 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
<valid>!0.0:</valid>
</arg>
</function>
<!-- https://cplusplus.com/reference/cmath/lgamma/ -->
<!-- long double lgammal(long double x); -->
<function name="lgammal,std::lgammal">
<use-retval/>
Expand All @@ -3066,6 +3073,8 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/>
<arg nr="1" direction="in">
<not-uninit/>
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
<valid>!0.0:</valid>
</arg>
</function>
<!-- double rint(double x); -->
Expand Down
24 changes: 24 additions & 0 deletions test/cfg/std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2382,6 +2382,30 @@ void uninitvar_ldexp(void)
(void)std::ldexp(ldc,e3);
}

void invalidFunctionArg_lgamma(float f, double d, long double ld)
{
(void)lgamma(d);
// cppcheck-suppress invalidFunctionArg
(void)lgamma(-0.1);
// cppcheck-suppress invalidFunctionArg
(void)lgamma(0.0);
(void)lgamma(0.1);

(void)lgammaf(f);
// cppcheck-suppress invalidFunctionArg
(void)lgammaf(-0.1f);
// cppcheck-suppress invalidFunctionArg
(void)lgammaf(0.0f);
(void)lgammaf(0.1f);

(void)lgammal(ld);
// cppcheck-suppress invalidFunctionArg
(void)lgammal(-0.1L);
// cppcheck-suppress invalidFunctionArg
(void)lgammal(0.0L);
(void)lgammal(0.1L);
}

void uninitvar_lgamma(void)
{
float f;
Expand Down

0 comments on commit 32cabec

Please sign in to comment.