From 8189339e7d132f388fed6e5ba2265ae0ff789671 Mon Sep 17 00:00:00 2001 From: Greg King Date: Wed, 1 Jul 2015 06:55:57 -0400 Subject: [PATCH] Added special-case compiler code that handles a pointer-to-array dereference. The type needs to change (to array); but, the address shouldn't be changed -- it already points to the first element. Based on a bug analysis by Daniel Serpell. --- src/cc65/expr.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index d615993c4..7563645ff 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1,7 +1,7 @@ /* expr.c ** ** 1998-06-21, Ullrich von Bassewitz -** 2015-04-19, Greg King +** 2015-06-26, Greg King */ @@ -1713,8 +1713,13 @@ void hie10 (ExprDesc* Expr) } else { Error ("Illegal indirection"); } - /* The * operator yields an lvalue */ - ED_MakeLVal (Expr); + /* If the expression points to an array, then don't convert the + ** address -- it already is the location of the first element. + */ + if (!IsTypeArray (Expr->Type)) { + /* The * operator yields an lvalue */ + ED_MakeLVal (Expr); + } } break;