File tree Expand file tree Collapse file tree 1 file changed +25
-5
lines changed
cpp/ql/test/query-tests/Likely Bugs/Conversion/ImplicitDowncastFromBitfield Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -2,22 +2,42 @@ typedef struct {
22 int x : 24 ;
33} my_struct;
44
5- int getX1 (my_struct m) {
5+ unsigned int getX1 (my_struct m) {
66 return m.x ;
77}
88
99short getX2 (my_struct m) {
10- return m.x ;
10+ return m.x ; // BAD
1111}
1212
1313short getX3 (my_struct m) {
14- return (short ) m.x ;
14+ return (short ) m.x ; // GOOD
1515}
1616
1717bool getX4 (my_struct m) {
18- return m.x ;
18+ return m.x ; // GOOD
1919}
2020
2121short getX5 (my_struct m) {
22- return (char ) m.x ;
22+ return (char ) m.x ; // GOOD
23+ }
24+
25+ const char & getx6 (my_struct& m) {
26+ const char & result = m.x ; // BAD [NOT DETECTED]
27+ return result;
28+ }
29+
30+ const short & getx7 (my_struct& m) {
31+ const short & result = (short ) m.x ; // GOOD
32+ return result;
33+ }
34+
35+ const int & getx8 (my_struct& m) {
36+ const int & result = m.x ; // GOOD
37+ return result;
38+ }
39+
40+ const bool & getx9 (my_struct& m) {
41+ const bool & result = m.x ; // GOOD
42+ return result;
2343}
You can’t perform that action at this time.
0 commit comments