Skip to content

Commit 32cabec

Browse files
authored
Add support for InvalidFunctionArg lgamma() (#5845)
Reference: https://en.cppreference.com/w/cpp/numeric/math/lgamma
1 parent fde7ea6 commit 32cabec

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

cfg/std.cfg

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,6 +3035,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
30353035
<not-uninit/>
30363036
</arg>
30373037
</function>
3038+
<!-- https://cplusplus.com/reference/cmath/lgamma/ -->
30383039
<!-- double lgamma(double x); -->
30393040
<function name="lgamma,std::lgamma">
30403041
<use-retval/>
@@ -3044,8 +3045,11 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
30443045
<leak-ignore/>
30453046
<arg nr="1" direction="in">
30463047
<not-uninit/>
3048+
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
3049+
<valid>!0.0:</valid>
30473050
</arg>
30483051
</function>
3052+
<!-- https://cplusplus.com/reference/cmath/lgamma/ -->
30493053
<!-- float lgammaf(float x); -->
30503054
<function name="lgammaf,std::lgammaf">
30513055
<use-retval/>
@@ -3055,8 +3059,11 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
30553059
<leak-ignore/>
30563060
<arg nr="1" direction="in">
30573061
<not-uninit/>
3062+
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
3063+
<valid>!0.0:</valid>
30583064
</arg>
30593065
</function>
3066+
<!-- https://cplusplus.com/reference/cmath/lgamma/ -->
30603067
<!-- long double lgammal(long double x); -->
30613068
<function name="lgammal,std::lgammal">
30623069
<use-retval/>
@@ -3066,6 +3073,8 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
30663073
<leak-ignore/>
30673074
<arg nr="1" direction="in">
30683075
<not-uninit/>
3076+
<!-- If x is zero or a negative integer for which the function is asymptotic, it may cause a pole error (depending on implementation).-->
3077+
<valid>!0.0:</valid>
30693078
</arg>
30703079
</function>
30713080
<!-- double rint(double x); -->

test/cfg/std.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,6 +2382,30 @@ void uninitvar_ldexp(void)
23822382
(void)std::ldexp(ldc,e3);
23832383
}
23842384

2385+
void invalidFunctionArg_lgamma(float f, double d, long double ld)
2386+
{
2387+
(void)lgamma(d);
2388+
// cppcheck-suppress invalidFunctionArg
2389+
(void)lgamma(-0.1);
2390+
// cppcheck-suppress invalidFunctionArg
2391+
(void)lgamma(0.0);
2392+
(void)lgamma(0.1);
2393+
2394+
(void)lgammaf(f);
2395+
// cppcheck-suppress invalidFunctionArg
2396+
(void)lgammaf(-0.1f);
2397+
// cppcheck-suppress invalidFunctionArg
2398+
(void)lgammaf(0.0f);
2399+
(void)lgammaf(0.1f);
2400+
2401+
(void)lgammal(ld);
2402+
// cppcheck-suppress invalidFunctionArg
2403+
(void)lgammal(-0.1L);
2404+
// cppcheck-suppress invalidFunctionArg
2405+
(void)lgammal(0.0L);
2406+
(void)lgammal(0.1L);
2407+
}
2408+
23852409
void uninitvar_lgamma(void)
23862410
{
23872411
float f;

0 commit comments

Comments
 (0)