NetBSD Problem Report #22515

Received: (qmail 12572 invoked by uid 605); 17 Aug 2003 17:54:37 -0000
Message-Id: <20030817175427.531CBF3C1D@nutcracker.stacken.kth.se>
Date: Sun, 17 Aug 2003 19:54:27 +0200 (CEST)
From: lha@stacken.kth.se
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: lha@stacken.kth.se
To: gnats-bugs@gnats.netbsd.org
Subject: lint cares too much about comments
X-Send-Pr-Version: 3.95

>Number:         22515
>Category:       bin
>Synopsis:       lint cares too much about comments
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 17 17:55:00 +0000 2003
>Closed-Date:    
>Last-Modified:  Wed Jun 09 03:10:01 +0000 2021
>Originator:     Love
>Release:        NetBSD 1.6W
>Organization:
	SU
>Environment:
System: NetBSD nutcracker.stacken.kth.se 1.6W NetBSD 1.6W (NUTCRACKER) #32: Thu Aug 7 00:14:40 CEST 2003 lha@nutcracker.stacken.kth.se:/usr/src/sys/arch/i386/compile/NUTCRACKER i386
Architecture: i386
Machine: i386
>Description:

lint cares about comments in defines

>How-To-Repeat:

	$ cat > lint-define.c
	#define LINTFOO 1  /* comment */
	#define LINTFOO 1  /* diffrent */ 
	int foo;
	$ gcc -Wall -c lint-define.c 
	$ lint -z -v -u lint-define.c
	lint-define.c:
	lint-define.c:2: warning: `LINTFOO' redefined
	lint-define.c:1: warning: this is the location of the previous definition
	Lint pass2:

while


	$ cat > lint-define.c
	#define LINTFOO 1  /* comment */
	#define LINTFOO 1  /* comment */
	$ gcc -Wall -c lint-define.c 
	$ lint -z -v -u lint-define.c
	lint-define.c:
	Lint pass2:

is just fine

>Fix:

what should the behavior be ?
>Release-Note:
>Audit-Trail:

From: "Lagno, DenisX" <denisx.lagno@intel.com>
To: <lha@stacken.kth.se>
Cc: <netbsd-bugs@NetBSD.org>
Subject: RE: bin/22515: lint cares too much about comments
Date: Mon, 18 Aug 2003 14:02:52 +0400

 I think lint is right.  All text after #define XXX considered as =
 replacement list.  The following citation is from C++ standard though I =
 think it is valid for C also:

   16.3  Macro replacement                                  [cpp.replace]

 1 Two  replacement  lists are identical if and only if the preprocessing
   tokens in both have the same number, ordering,  spelling,  and  white-
   space  separation,  where  all  white-space separations are considered
   identical.

 2 An identifier currently defined as a macro without use of  lparen  (an
   object-like  macro)  may be redefined by another #define preprocessing
   directive provided that the second definition is an object-like  macro
   definition  and the two replacement lists are identical, otherwise the
   program is ill-formed.

 > -----Original Message-----
 > Subject: bin/22515: lint cares too much about comments
 > To: None <gnats-bugs@gnats.netbsd.org>
 > From: None <lha@stacken.kth.se>
 > List: netbsd-bugs
 > Date: 08/17/2003 19:54:27=20
 > >Number:         22515
 > >Category:       bin
 > >Synopsis:       lint cares too much about comments
 > >Confidential:   no
 > >Severity:       non-critical
 > >Priority:       low
 > >Responsible:    bin-bug-people
 > >State:          open
 > >Class:          sw-bug
 > >Submitter-Id:   net
 > >Arrival-Date:   Sun Aug 17 17:55:00 UTC 2003
 > >Closed-Date:
 > >Last-Modified:
 > >Originator:     Love
 > >Release:        NetBSD 1.6W
 > >Organization:
 > 	SU
 > >Environment:
 > System: NetBSD nutcracker.stacken.kth.se 1.6W NetBSD 1.6W=20
 > (NUTCRACKER) #32: Thu Aug 7 00:14:40 CEST 2003=20
 > lha@nutcracker.stacken.kth.se:/usr/src/sys/arch/i386/compile/N
 > UTCRACKER i386
 > Architecture: i386
 > Machine: i386
 > >Description:
 >=20
 > lint cares about comments in defines
 >=20
 > >How-To-Repeat:
 >=20
 > 	$ cat > lint-define.c
 > 	#define LINTFOO 1  /* comment */
 > 	#define LINTFOO 1  /* diffrent */=20
 > 	int foo;
 > 	$ gcc -Wall -c lint-define.c=20
 > 	$ lint -z -v -u lint-define.c
 > 	lint-define.c:
 > 	lint-define.c:2: warning: `LINTFOO' redefined
 > 	lint-define.c:1: warning: this is the location of the=20
 > previous definition
 > 	Lint pass2:
 >=20
 > while
 >=20
 >=20
 > 	$ cat > lint-define.c
 > 	#define LINTFOO 1  /* comment */
 > 	#define LINTFOO 1  /* comment */
 > 	$ gcc -Wall -c lint-define.c=20
 > 	$ lint -z -v -u lint-define.c
 > 	lint-define.c:
 > 	Lint pass2:
 >=20
 > is just fine
 >=20
 > >Fix:
 >=20
 > what should the behavior be ?
 > >Release-Note:
 > >Audit-Trail:
 > >Unformatted:
 >=20


From: "Lagno, DenisX" <denisx.lagno@intel.com>
To: <lha@stacken.kth.se>
Cc: <netbsd-bugs@NetBSD.org>
Subject: RE: bin/22515: lint cares too much about comments
Date: Mon, 18 Aug 2003 14:02:52 +0400

 I think lint is right.  All text after #define XXX considered as =
 replacement list.  The following citation is from C++ standard though I =
 think it is valid for C also:

   16.3  Macro replacement                                  [cpp.replace]

 1 Two  replacement  lists are identical if and only if the preprocessing
   tokens in both have the same number, ordering,  spelling,  and  white-
   space  separation,  where  all  white-space separations are considered
   identical.

 2 An identifier currently defined as a macro without use of  lparen  (an
   object-like  macro)  may be redefined by another #define preprocessing
   directive provided that the second definition is an object-like  macro
   definition  and the two replacement lists are identical, otherwise the
   program is ill-formed.

 > -----Original Message-----
 > Subject: bin/22515: lint cares too much about comments
 > To: None <gnats-bugs@gnats.netbsd.org>
 > From: None <lha@stacken.kth.se>
 > List: netbsd-bugs
 > Date: 08/17/2003 19:54:27=20
 > >Number:         22515
 > >Category:       bin
 > >Synopsis:       lint cares too much about comments
 > >Confidential:   no
 > >Severity:       non-critical
 > >Priority:       low
 > >Responsible:    bin-bug-people
 > >State:          open
 > >Class:          sw-bug
 > >Submitter-Id:   net
 > >Arrival-Date:   Sun Aug 17 17:55:00 UTC 2003
 > >Closed-Date:
 > >Last-Modified:
 > >Originator:     Love
 > >Release:        NetBSD 1.6W
 > >Organization:
 > 	SU
 > >Environment:
 > System: NetBSD nutcracker.stacken.kth.se 1.6W NetBSD 1.6W=20
 > (NUTCRACKER) #32: Thu Aug 7 00:14:40 CEST 2003=20
 > lha@nutcracker.stacken.kth.se:/usr/src/sys/arch/i386/compile/N
 > UTCRACKER i386
 > Architecture: i386
 > Machine: i386
 > >Description:
 >=20
 > lint cares about comments in defines
 >=20
 > >How-To-Repeat:
 >=20
 > 	$ cat > lint-define.c
 > 	#define LINTFOO 1  /* comment */
 > 	#define LINTFOO 1  /* diffrent */=20
 > 	int foo;
 > 	$ gcc -Wall -c lint-define.c=20
 > 	$ lint -z -v -u lint-define.c
 > 	lint-define.c:
 > 	lint-define.c:2: warning: `LINTFOO' redefined
 > 	lint-define.c:1: warning: this is the location of the=20
 > previous definition
 > 	Lint pass2:
 >=20
 > while
 >=20
 >=20
 > 	$ cat > lint-define.c
 > 	#define LINTFOO 1  /* comment */
 > 	#define LINTFOO 1  /* comment */
 > 	$ gcc -Wall -c lint-define.c=20
 > 	$ lint -z -v -u lint-define.c
 > 	lint-define.c:
 > 	Lint pass2:
 >=20
 > is just fine
 >=20
 > >Fix:
 >=20
 > what should the behavior be ?
 > >Release-Note:
 > >Audit-Trail:
 > >Unformatted:
 >=20


From: Krister Walfridsson <cato@df.lth.se>
To: lha@stacken.kth.se
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/22515: lint cares too much about comments
Date: Mon, 18 Aug 2003 22:34:41 +0200 (MEST)

 > >Description:
 >
 > lint cares about comments in defines
 >
 > >How-To-Repeat:
 >
 > 	$ cat > lint-define.c
 > 	#define LINTFOO 1  /* comment */
 > 	#define LINTFOO 1  /* diffrent */
 > 	int foo;
 > 	$ gcc -Wall -c lint-define.c
 > 	$ lint -z -v -u lint-define.c
 > 	lint-define.c:
 > 	lint-define.c:2: warning: `LINTFOO' redefined
 > 	lint-define.c:1: warning: this is the location of the previous definition
 > 	Lint pass2:

 Note that this warning does not come from lint...  lint uses gcc as the
 pre-processor, and running gcc with the flags normally passed by lint
 gives the warning:

 /usr/bin/cc -E -x c -U__GNUC__ -Wp,-$ -Wp,-CC -Wcomment -D__LINT__ -Dlint -D__lint -D__lint__ -Wtraditional lint-define.c
 lint-define.c:2: warning: `LINTFOO' redefined
 lint-define.c:1: warning: this is the location of the previous definition

    /Krister


From: Love <lha@stacken.kth.se>
To: Krister Walfridsson <cato@df.lth.se>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/22515: lint cares too much about comments
Date: Mon, 18 Aug 2003 22:47:56 +0200

 --=-=-=
 Content-Transfer-Encoding: quoted-printable


 Krister Walfridsson <cato@df.lth.se> writes:

 > Note that this warning does not come from lint...  lint uses gcc as the
 > pre-processor, and running gcc with the flags normally passed by lint
 > gives the warning:

 Ok, so the warning is from gcc. So lint is not to blame other that it makes
 gcc turn on the warning.

 My real problem is that all programs that uses lint and includes <des.h>
 and <openssl/des.h> gets this warning.

 : lha@nutcracker ; grep 'define DES_KEY_SZ' /usr/include/{openssl/,}des.h
 /usr/include/openssl/des.h:#define DES_KEY_SZ 8/*(sizeof(DES_cblock))*/
 /usr/include/des.h:#define DES_KEY_SZ        8/*(sizeof(des_cblock))*/


 Also, is the warning correct or just overly pedantic ?

 Love


 --=-=-=
 Content-Type: application/pgp-signature

 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.2 (NetBSD)

 iQEVAwUAP0E7f3W+NPVfDpmCAQIUigf/ebzhNABycRJ1An61rKlT7WPoW/G3Ky50
 vUftQcc5JaEZh7qKg2yNKzis0o6uA30ihyFdT+RxNIkS+i597cFDtBJWC6aCi5QT
 gso2MWlv0ypfwVI9CLIwrUYyimXbDRnu4k2s/sCJi/dDvsc76kwQZHnrRW87TxkU
 nuMRnhyenVJBxXVvZ46kDh6+8IptvOo8nH6DGUOZu8u5Vr4kQcIYUI2SDQOeOTYz
 LLnAIQ/7h3OI+JaekUpCfr5blo8uFaYEE3VA4YrmTZFtsTWv5W5hvLG5quTfk1Km
 WsAGwykSA0eveDEQ3ZwdhS3UZXB5FmzAR9ftFWNcrXt0qWFKCM+LsQ==
 =bfx/
 -----END PGP SIGNATURE-----
 --=-=-=--

From: Krister Walfridsson <cato@df.lth.se>
To: Love <lha@stacken.kth.se>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: bin/22515: lint cares too much about comments
Date: Mon, 18 Aug 2003 23:41:41 +0200 (MEST)

 On Mon, 18 Aug 2003, Love wrote:

 > Ok, so the warning is from gcc. So lint is not to blame other that it makes
 > gcc turn on the warning.
 >
 > My real problem is that all programs that uses lint and includes <des.h>
 > and <openssl/des.h> gets this warning.
 >
 > : lha@nutcracker ; grep 'define DES_KEY_SZ' /usr/include/{openssl/,}des.h
 > /usr/include/openssl/des.h:#define DES_KEY_SZ 8/*(sizeof(DES_cblock))*/
 > /usr/include/des.h:#define DES_KEY_SZ        8/*(sizeof(des_cblock))*/
 >
 >
 > Also, is the warning correct or just overly pedantic ?

 I agree with your interpretation of the standard, i.e. your usage is
 well defined.

 OTOH, you could argue that lint's job is to be overly pedantic... ;)

 But after looking some at the gcc source, I am rather sure that this
 is a bug in gcc.  I'll look some more on this, and discuss this on
 the gcc mailing list if I still think it is a bug after my
 investigation...

    /Krister

Responsible-Changed-From-To: bin-bug-people->kristerw 
Responsible-Changed-By: kristerw 
Responsible-Changed-When: Mon Aug 18 21:43:04 UTC 2003 
Responsible-Changed-Why:  
I'll deal with this. 
Responsible-Changed-From-To: kristerw->bin-bug-people
Responsible-Changed-By: rillig@NetBSD.org
Responsible-Changed-When: Sun, 28 Feb 2021 20:27:34 +0000
Responsible-Changed-Why:
Reassign to bin-bug-people due to inactivity.
Still reproducible on NetBSD 9.99.80 using GCC 9.3.0.
The crucial option that lint passes to cc is -Wp,-CC,
which it needs for preserving comments like /*LINTED*/.


From: Roland Illig <roland.illig@gmx.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/22515 (lint cares too much about comments)
Date: Sun, 28 Feb 2021 22:17:10 +0100

 C99 5.1.1.2 item 3 says:
  > The source file is decomposed into preprocessing tokens
  > and sequences of white-space characters (including comments).
  >
  > Each comment is replaced by one space character.

 This is the usual translation mode required by C99.  GCC's -CC option
 for preserving all comments is not mentioned there because there is no
 reason to preserve comments, except for some linters.

 The manual page of GNU cpp 9.3.0 says:
  > Do not discard comments, [...]
  >
  > The -CC option is generally used to support lint comments.

 It's debatable whether a difference in the comment should be considered
 different since that is outside the scope of Standard C.

 GNU cpp sees it as different, and I didn't find a compiler flag to
 suppress this kind of warnings.  Reading through libcpp/macro.c did not
 reveal any obvious way to suppress these warnings either.

 I described the scenario here:
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D83773#c4

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/22515 (lint cares too much about comments)
Date: Wed, 9 Jun 2021 03:06:24 +0000

 On Sun, Feb 28, 2021 at 09:20:01PM +0000, Roland Illig wrote:
  >   > The -CC option is generally used to support lint comments.
  >  
  >  It's debatable whether a difference in the comment should be considered
  >  different since that is outside the scope of Standard C.

 It is and it isn't; there's no reason to think that the option
 (preserve comments in the _output_) should affect the _interpretation_
 of the text.

 Consequently I'd consider it a cpp bug, though I also understand why
 it happens and it would be a nuisance to fix.

 In the long run lint should probably grow its own cpp that can lint
 cpp usage. (Or import one, or go away entirely in favor of a better
 program checker, etc.)

 -- 
 David A. Holland
 dholland@netbsd.org

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.