Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: document that C99-style initializa...



details:   https://anonhg.NetBSD.org/src/rev/f76c097d5424
branches:  trunk
changeset: 979574:f76c097d5424
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jan 01 19:28:51 2021 +0000

description:
lint: document that C99-style initialization is necessarily buggy

diffstat:

 usr.bin/xlint/lint1/init.c |  17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r 576a50daa83c -r f76c097d5424 usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Fri Jan 01 19:15:58 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Fri Jan 01 19:28:51 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.53 2021/01/01 19:15:58 rillig Exp $ */
+/*     $NetBSD: init.c,v 1.54 2021/01/01 19:28:51 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.53 2021/01/01 19:15:58 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.54 2021/01/01 19:28:51 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -49,6 +49,19 @@
 
 /*
  * Type of stack which is used for initialisation of aggregate types.
+ *
+ * XXX: Since C99, a stack is an inappropriate data structure for modelling
+ * an initialization, since the designators don't have to be listed in a
+ * particular order and can designate parts of sub-objects.  The member names
+ * of non-leaf structs may thus appear repeatedly, as demonstrated in
+ * d_init_pop_member.c.
+ *
+ * XXX: During initialization, there may be members of the top-level struct
+ * that are partially initialized.  The simple i_remaining cannot model this
+ * appropriately.
+ *
+ * See C99 6.7.8, which spans 6 pages full of tricky details and carefully
+ * selected examples.
  */
 typedef        struct istk {
        type_t  *i_type;                /* type of initialisation */



Home | Main Index | Thread Index | Old Index