From da63695cf3ee85dc4a2f914d278cf90873cd0052 Mon Sep 17 00:00:00 2001 From: "Pavlas, Zdenek" Date: Mon, 3 Oct 2016 00:40:37 -0700 Subject: switch: fix label sorting --- tccgen.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tccgen.c') diff --git a/tccgen.c b/tccgen.c index 398e165..6f7cf1f 100644 --- a/tccgen.c +++ b/tccgen.c @@ -4881,8 +4881,12 @@ static void label_or_decl(int l) decl(l); } -static int case_cmp(const void *a, const void *b) -{ return (*(struct case_t**) a)->v1 - (*(struct case_t**) b)->v1; } +static int case_cmp(const void *pa, const void *pb) +{ + int a = (*(struct case_t**) pa)->v1; + int b = (*(struct case_t**) pb)->v1; + return a < b ? -1 : a > b; +} static void block(int *bsym, int *csym, int is_expr) { -- cgit v1.3.1