File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
cpp/ql/test/query-tests/JPL_C/LOC-4/Rule 29/NonConstFunctionPointer Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ | test.c:18:2:18:10 | call to expression | This call does not go through a const function pointer. |
2+ | test.c:19:2:19:10 | call to expression | This call does not go through a const function pointer. |
3+ | test.c:20:2:20:10 | call to expression | This call does not go through a const function pointer. |
Original file line number Diff line number Diff line change 1+ JPL_C/LOC-4/Rule 29/NonConstFunctionPointer.ql
Original file line number Diff line number Diff line change 1+ // test.c
2+
3+ void myFunc1 ();
4+ void myFunc2 ();
5+
6+ typedef void (* voidFunPointer )();
7+
8+ void test ()
9+ {
10+ void (* funPtr1 )() = & myFunc1 ;
11+ const void (* funPtr2 )() = & myFunc1 ;
12+ const voidFunPointer funPtr3 = & myFunc1 ;
13+
14+ funPtr1 = & myFunc2 ;
15+ funPtr2 = & myFunc2 ;
16+ //funPtr3 = &myFunc2; --- this would be a compilation error
17+
18+ funPtr1 (); // BAD
19+ funPtr2 (); // BAD
20+ funPtr3 (); // GOOD [FALSE POSITIVE]
21+ }
You can’t perform that action at this time.
0 commit comments