File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
cpp/ql/src/Security/CWE/CWE-843 Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,20 @@ class UnsafeCast extends Cast {
139139
140140 Class getConvertedType ( ) { result = toType }
141141
142+ /**
143+ * Holds if the result of this cast can safely be interpreted as a value of
144+ * type `t`.
145+ *
146+ * The compatibility rules are as follows:
147+ *
148+ * 1. the result of `(T)x` is compatible with the type `T` for any `T`
149+ * 2. the result of `(T)x` is compatible with the type `U` for any `U` such
150+ * that `U` is a subtype of `T`, or `T` is a subtype of `U`.
151+ * 3. the result of `(T)x` is compatible with the type `U` if `U` the list
152+ * of fields of `U` is a prefix of the list of fields of `T`.
153+ * For example, if `T` is `struct { unsigned char x; int y; };`
154+ * and `U` is `struct { unsigned char uc; };`.
155+ */
142156 bindingset [ this , t]
143157 pragma [ inline_late]
144158 predicate compatibleWith ( Type t ) {
You can’t perform that action at this time.
0 commit comments