Module Name:    src
Committed By:   rillig
Date:           Fri Apr  1 01:06:26 UTC 2022

Modified Files:
        src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: replace crash with assertion failure

Triggered by 'sizeof(int())'.

GCC evaluates this expression to 1, without any warning.

Clang warns about an "invalid application of 'sizeof' to a function
type".


To generate a diff of this commit:
cvs rdiff -u -r1.411 -r1.412 src/usr.bin/xlint/lint1/tree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.411 src/usr.bin/xlint/lint1/tree.c:1.412
--- src/usr.bin/xlint/lint1/tree.c:1.411	Sun Mar 13 15:26:54 2022
+++ src/usr.bin/xlint/lint1/tree.c	Fri Apr  1 01:06:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.411 2022/03/13 15:26:54 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.412 2022/04/01 01:06:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.411 2022/03/13 15:26:54 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.412 2022/04/01 01:06:26 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -3473,6 +3473,7 @@ type_size_in_bits(const type_t *tp)
 
 	elem = 1;
 	flex = false;
+	lint_assert(tp != NULL);
 	while (tp->t_tspec == ARRAY) {
 		flex = true;	/* allow c99 flex arrays [] [0] */
 		elem *= tp->t_dim;

Reply via email to