diff mbox

returns the correct type when evaluating NULL

Message ID 20170306044349.16869-1-luc.vanoostenryck@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Luc Van Oostenryck March 6, 2017, 4:43 a.m. UTC
In evaluate_cast(), the expression '(void*)<some zero constant>',
aka 'NULL', is detected and given the type 'null_ctype',
a special kind of pointer type.
However the returned type is the original one: 'void *'.

This doesn't seem to be intented as in all other cases, the
evaluate_...() functions and ultimately evaluate_expression()
always return the type of the expression.

Fix this by returning the type given to the expression: null_ctype.

Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 evaluate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/evaluate.c b/evaluate.c
index 47eeaef2e..440d05da6 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -2844,7 +2844,7 @@  static struct symbol *evaluate_cast(struct expression *expr)
 				expr->type = EXPR_VALUE;
 				expr->ctype = &null_ctype;
 				expr->value = 0;
-				return ctype;
+				return expr->ctype;
 			}
 		}
 	}