File tree Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Expand file tree Collapse file tree 3 files changed +35
-2
lines changed Original file line number Diff line number Diff line change
1
+ ` M9-3-3 ` : ` MemberFunctionConstIfPossible.ql ` :
2
+ - Fix FP reported in 467. Excluding candidates in uninstantiated templates.
Original file line number Diff line number Diff line change @@ -54,7 +54,10 @@ class ConstMemberFunctionCandidate extends NonConstMemberFunction {
54
54
not this instanceof Destructor and
55
55
not this instanceof Operator and
56
56
//less interested in MemberFunctions with no definition
57
- this .hasDefinition ( )
57
+ this .hasDefinition ( ) and
58
+ // For uninstantiated templates we have only partial information that prevents us from determining
59
+ // if the candidate calls non-const functions. Therefore we exclude these.
60
+ not this .isFromUninstantiatedTemplate ( _)
58
61
}
59
62
60
63
/**
Original file line number Diff line number Diff line change @@ -162,6 +162,34 @@ class Z22 : Z1 {
162
162
void f3 () { this ->a = 100 ; } // COMPLIANT
163
163
};
164
164
165
+ template <class T > class Array {
166
+ public:
167
+ T &back ();
168
+
169
+ private:
170
+ T data[128 ];
171
+ unsigned int size;
172
+ };
173
+
174
+ template <class T , template <class ...> class U > class Stack {
175
+ public:
176
+ T &Top () {
177
+ return this ->data .back ();
178
+ } // COMPLIANT[FALSE_NEGATIVE|TRUE_NEGATIVE] - exception not specified in the
179
+ // standard, we opt to not raise an issue because the template can be both
180
+ // compliant and non-compliant depending on instantiations.
181
+ private:
182
+ U<T> data;
183
+ };
184
+
185
+ using IntVectorStack = Stack<int , Array>;
186
+
187
+ void test_template () {
188
+ IntVectorStack s;
189
+
190
+ int i = s.Top ();
191
+ }
192
+
165
193
class Z3 {
166
194
void f (int ) = delete; // COMPLIANT
167
- };
195
+ };
You can’t perform that action at this time.
0 commit comments