NetBSD Problem Report #46223

From www@NetBSD.org  Sun Mar 18 20:13:37 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 11F3163E1C2
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 18 Mar 2012 20:13:37 +0000 (UTC)
Message-Id: <20120318201336.6245363B946@www.NetBSD.org>
Date: Sun, 18 Mar 2012 20:13:36 +0000 (UTC)
From: Markus.Elfring@web.de
Reply-To: Markus.Elfring@web.de
To: gnats-bugs@NetBSD.org
Subject: reserved identifier violation
X-Send-Pr-Version: www-1.0

>Number:         46223
>Category:       standards
>Synopsis:       reserved identifier violation
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    standards-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 18 20:15:01 +0000 2012
>Closed-Date:    Sun Mar 18 21:23:37 +0000 2012
>Last-Modified:  Sat Apr 14 05:50:02 +0000 2012
>Originator:     Markus Elfring
>Release:        
>Organization:
>Environment:
>Description:
I have looked at a few header files. I see that include guards like "_AIO_H_" and "_WORDEXP_H_" are used.
http://cvsweb.netbsd.org/bsdweb.cgi/src/include/aio.h?rev=1.7&content-type=text/x-cvsweb-markup&only_with_tag=MAIN
http://cvsweb.netbsd.org/bsdweb.cgi/src/include/wordexp.h?rev=1.2&content-type=text/x-cvsweb-markup&only_with_tag=MAIN

I am informed that such a name pattern (leading underscore and a following uppercase letter) is reserved for the use in implementations of compilers for the programming languages C and C++.
https://www.securecoding.cert.org/confluence/display/cplusplus/DCL32-CPP.+Do+not+declare+or+define+a+reserved+identifier#DCL32-CPP.Donotdeclareordefineareservedidentifier-NoncompliantCodeExample%28HeaderGuard%29

I assume that a couple of header files do not belong to C/C++ compiler
implementations here but to operating system implementations. Do any preprocessor symbols need further adjustments to make them completely standard-compliant?
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: standards/46223: reserved identifier violation
Date: Sun, 18 Mar 2012 20:22:22 +0000

 On Sun, Mar 18, 2012 at 08:15:01PM +0000, Markus.Elfring@web.de wrote:
  > I have looked at a few header files. I see that include guards like
  > "_AIO_H_" and "_WORDEXP_H_" are used.
  > [...]
  > I am informed that such a name pattern (leading underscore and a
  > following uppercase letter) is reserved for the use in
  > implementations of compilers for the programming languages C and
  > C++.

 No, they are reserved for use by "the implementation", which includes
 the OS.

 -- 
 David A. Holland
 dholland@netbsd.org

From: Markus Elfring <Markus.Elfring@web.de>
To: David Holland <dholland-bugs@netbsd.org>
Cc: gnats-bugs@NetBSD.org
Subject: Re: standards/46223: reserved identifier violation
Date: Sun, 18 Mar 2012 21:55:18 +0100

 >   No, they are reserved for use by "the implementation", which includes
 >   the OS.

 Do source files exist in your repository which tamper with the name space
 that is reserved for identifiers in C/C++ compiler implementations?

 Are there identifiers that belong more to other software applications than the 
 compiler and operating system combination?

 Regards,
 Markus

State-Changed-From-To: open->closed
State-Changed-By: kleink@NetBSD.org
State-Changed-When: Sun, 18 Mar 2012 21:23:37 +0000
State-Changed-Why:
This is not a bug.

The cited reference applies to applications, and not to the implementation
(compiler, library, OS) of the specification (standard). The headers
shipped with NetBSD are part of the implementation; changing them as
recommended in the reference would pollute application namespace.      

Please consult any recent C standard, section 7.1.3 ("Reserved 
identifiers") for reference ("All identiļ¬ers that begin with an
underscore and either an uppercase letter or another underscore
are always reserved for anyuse.", see also paragraph #2), or
the Open Group Base Specifications Issue 7, System Interfaces 2.2.2
("The Name Space") at http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_02_02
("With the exception of identifiers beginning with the prefix _POSIX_,        n all identifiers that begin with an <underscore> and either an
uppercase letter or another <underscore> are always reserved for
any use by the implementation.")

If you come across a problem caused by a system header violating
those constraints, please submit a new PR in this category.


From: Klaus Klein <kleink@kleink.org>
To: gnats-bugs@NetBSD.org
Cc: standards-manager@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, Markus.Elfring@web.de
Subject: Re: standards/46223: reserved identifier violation
Date: Sun, 18 Mar 2012 22:50:42 +0100

 On Sun, Mar 18, 2012 at 09:00:13PM +0000, Markus Elfring wrote:

 >  Do source files exist in your repository which tamper with the name space
 >  that is reserved for identifiers in C/C++ compiler implementations?

 Absolutely; you've referenced two of those. However, all of this
 is implementation namespace.

 >  Are there identifiers that belong more to other software applications than the 
 >  compiler and operating system combination?

 A standard specifies which identifiers names are reserved for use by
 the implementation; see http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_02_02
 for one such instance. Other application software, such as 3rd-party
 libraries, usually have their own conventions of reserved identifiers
 or prefixes (such as possibly g_ in GLib) which are not to be tampered
 with by "applications", but as far as implementations are concerned,
 all applications are created equal.


 Regards,
 - Klaus

From: Markus Elfring <Markus.Elfring@web.de>
To: Klaus Klein <kleink@kleink.org>
Cc: gnats-bugs@NetBSD.org, standards-manager@netbsd.org, 
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, 
 Antoine Leca <antoine.leca.1@gmail.com>
Subject: Re: standards/46223: reserved identifier violation
Date: Tue, 03 Apr 2012 19:30:55 +0200

 >>   Are there identifiers that belong more to other software applications than the
 >>   compiler and operating system combination?
 >
 > A standard specifies which identifiers names are reserved for use by
 > the implementation;

 I assume that different opinions exist about the categorisation which components 
 belong to a conforming freestanding or hosted C/C++ implementation.
 An operating system might belong to an freestanding environment.

 Do identifiers exist which should be treated as separate items from such a 
 system configuration?

 Regards,
 Markus

From: David Holland <dholland-bugs@netbsd.org>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: gnats-bugs@NetBSD.org
Subject: Re: standards/46223: reserved identifier violation
Date: Fri, 13 Apr 2012 00:54:04 +0000

 On Tue, Apr 03, 2012 at 07:30:55PM +0200, Markus Elfring wrote:
  > >>  Are there identifiers that belong more to other software applications than the
  > >>  compiler and operating system combination?
  > >
  > >A standard specifies which identifiers names are reserved for use by
  > >the implementation;
  > 
  > I assume that different opinions exist about the categorisation
  > which components belong to a conforming freestanding or hosted
  > C/C++ implementation.
  > An operating system might belong to an freestanding environment.
  > 
  > Do identifiers exist which should be treated as separate items from
  > such a system configuration?

 I don't understand the question.

 -- 
 David A. Holland
 dholland@netbsd.org

From: Markus Elfring <Markus.Elfring@web.de>
To: David Holland <dholland-bugs@netbsd.org>
Cc: gnats-bugs@NetBSD.org, Antoine Leca <antoine.leca.1@gmail.com>
Subject: Re: standards/46223: reserved identifier violation
Date: Fri, 13 Apr 2012 14:15:46 +0200

 > I don't understand the question.

 I guess that it can be reworded like the following:
 Do you know any affected identifiers in your source code repository which do not 
 belong to a conforming C/C++ implementation?

 Do source files like the following show any update candidates?
 http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/csh/pathnames.h?rev=1.8&content-type=text/x-cvsweb-markup
 http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/ksh/sigact.h?rev=1.3&content-type=text/x-cvsweb-markup
 http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/stty/extern.h?rev=1.12&content-type=text/x-cvsweb-markup
 http://cvsweb.netbsd.org/bsdweb.cgi/src/crypto/dist/ipsec-tools/src/libipsec/libpfkey.h?rev=1.19&content-type=text/x-cvsweb-markup
 http://cvsweb.netbsd.org/bsdweb.cgi/src/dist/pdisk/DoSCSICommand.h?rev=1.2&content-type=text/x-cvsweb-markup
 http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.sbin/ypserv/common/ypdef.h?rev=1.5&content-type=text/x-cvsweb-markup

 Regards,
 Markus

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: standards/46223: reserved identifier violation
Date: Fri, 13 Apr 2012 14:32:19 +0200

 It seems you do not understand the separation between applications and the
 language implementation/toolchain/system libraries and that NetBSD contains
 a lot of both, plus the freestanding kernel.

 If you want to improve standard conformance and portability of some of the
 applications included in NetBSD base, please file PRs with tested patches
 individually for each application.

 Martin

From: Markus Elfring <Markus.Elfring@web.de>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@NetBSD.org, standards-manager@netbsd.org, 
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: standards/46223: reserved identifier violation
Date: Fri, 13 Apr 2012 15:00:53 +0200

 >   It seems you do not understand the separation between applications and the
 >   language implementation/toolchain/system libraries and that NetBSD contains
 >   a lot of both, plus the freestanding kernel.

 I would appreciate if this separation of application domains will become clearer 
 with further explanations for the source file hierarchy.

 Regards,
 Markus

From: Klaus Klein <kleink@kleink.org>
To: Markus.Elfring@web.de
Cc: gnats-bugs@NetBSD.org
Subject: Re: standards/46223: reserved identifier violation
Date: Fri, 13 Apr 2012 18:09:22 +0200

 On Fri, Apr 13, 2012 at 12:20:04PM +0000, Markus Elfring wrote:
 > The following reply was made to PR standards/46223; it has been noted by GNATS.
 > 
 > From: Markus Elfring <Markus.Elfring@web.de>
 > To: David Holland <dholland-bugs@netbsd.org>
 > Cc: gnats-bugs@NetBSD.org, Antoine Leca <antoine.leca.1@gmail.com>
 > Subject: Re: standards/46223: reserved identifier violation
 > Date: Fri, 13 Apr 2012 14:15:46 +0200
 > 
 >  > I don't understand the question.

 Let me note that I've been wondering about this as well.  It's
 rather hard to tell which problem you are attempting to solve, as
 far as NetBSD is concerned - hence some of the delay in responding.

 >  I guess that it can be reworded like the following:
 >  Do you know any affected identifiers in your source code repository which do not 
 >  belong to a conforming C/C++ implementation?

 Absolutely:

 >  Do source files like the following show any update candidates?
 >  http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/csh/pathnames.h?rev=1.8&content-type=text/x-cvsweb-markup
 >  http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/ksh/sigact.h?rev=1.3&content-type=text/x-cvsweb-markup
 >  http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/stty/extern.h?rev=1.12&content-type=text/x-cvsweb-markup
 >  http://cvsweb.netbsd.org/bsdweb.cgi/src/crypto/dist/ipsec-tools/src/libipsec/libpfkey.h?rev=1.19&content-type=text/x-cvsweb-markup
 >  http://cvsweb.netbsd.org/bsdweb.cgi/src/dist/pdisk/DoSCSICommand.h?rev=1.2&content-type=text/x-cvsweb-markup
 >  http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.sbin/ypserv/common/ypdef.h?rev=1.5&content-type=text/x-cvsweb-markup

 Those files aren't part of the implementation.

 With regard to the organization of the source tree, please have a
 look at hier(7).  Installing the OS, or at the very least extracting
 the comp set, should provide you with an impression more useful
 than looking at identifiers defined in seemingly arbitrarily chosen
 header files from the source tree.

 Also, while problem reports helping with the improvement of NetBSD
 are appreciated very much, please note that non-bug discussion
 would be more appropriate on tech-userlevel or tech-toolchain,
 rather than an obscure category of the bug database.


 Regards
 - Klaus

From: Markus Elfring <Markus.Elfring@web.de>
To: Klaus Klein <kleink@kleink.org>
Cc: gnats-bugs@NetBSD.org, standards-manager@netbsd.org, 
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: standards/46223: reserved identifier violation
Date: Fri, 13 Apr 2012 18:30:48 +0200

 >   It's rather hard to tell which problem you are attempting to solve,
 >   as far as NetBSD is concerned - hence some of the delay in responding.

 I dare to point out open issues in the standard-compliant application of C/C++ 
 naming conventions. A next step is the clarification for the willingness to 
 integrate corresponding source code adjustments.

 Regards,
 Markus

From: Klaus Klein <kleink@kleink.org>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: gnats-bugs@NetBSD.org
Subject: Re: standards/46223: reserved identifier violation
Date: Fri, 13 Apr 2012 19:52:46 +0200

 On Fri, Apr 13, 2012 at 06:30:48PM +0200, Markus Elfring wrote:
 > >  It's rather hard to tell which problem you are attempting to solve,
 > >  as far as NetBSD is concerned - hence some of the delay in responding.
 > 
 > I dare to point out open issues in the standard-compliant
 > application of C/C++ naming conventions.

 This sentence of yours is the quintessence of what makes the trail
 of this PR so puzzling, at least as far as I'm concerned.

 In addition, initially you reported the use of implementation-reserved
 identifier names in headers which would be part of the implementation
 (of POSIX, to be fair); subsequently you suggested a list of header
 files which are for the most part private to the respective
 applications or libraries residing in the same leaves of the source
 tree.  The former isn't a bug; the latter has a different scope
 and would be an issue only to those attempting to turn those
 directories' contents into conforming applications.

 Please submit issues (included fixes are appreciated, too) in new
 problem reports, or take further discussion to one of our tech
 lists; the bug database isn't the right place for this.


 Regards,
 - Klaus

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: standards/46223: reserved identifier violation
Date: Sat, 14 Apr 2012 02:31:21 +0700

     Date:        Fri, 13 Apr 2012 16:35:03 +0000 (UTC)
     From:        Markus Elfring <Markus.Elfring@web.de>
     Message-ID:  <20120413163503.5306963B9FE@www.NetBSD.org>

   |  I dare to point out open issues in the standard-compliant application
   |  of C/C++ naming conventions.

 Someone please close this PR - there cannot be a violation of this
 particular standards requirement in NetBSD - by definition.

 These "us vs them" rules that the standards guys like to impose
 upon the world are almost always disasters.   The problem is that
 there isn't just "us" & "them", or perhaps more accurately, there
 are a whole huge class of objects that can be either us or them,
 whichever one of those is not me.

 From a language standardiser's viewpoint, a rule like this seems to
 make sense, and "us" are the language standardisation committee, and
 "them" is everyone else (sometimes they're kind of gracious and admit
 implementors of the language as a part of the us group, but not always).

 This makes things simple, for this particular issue, it means that the
 language can always define new reserved magic words, and know that no
 user will ever be inconvenienced by that - or not unless the user has
 violated the rules.

 At the other extreme, the canonical example of "them" is the author of
 a "hello world" application - clearly such a person is not supposed to
 use _X identifiers, and if they do they are liable for whatever problems
 that causes them.  Of course, in 99% of cases, no-one is going to
 care what the author of such a program chooses to name their identifiers,
 as it never bothers anyone else in any way at all.  As long as it
 works, it is OK, whether it breaks  the rules or not.  The author is
 taking a (small) risk that if they move their application to another
 platform it may not build (or just perhaps, operate) correctly - that's
 a portability bug in the application, but as an application author,
 while that one is worth some consideration, there are far more insidious
 and harder to detect and deal with potential portability problems that
 I'd worry about much more than my choice of identifier names.

 In between we have everything else - the language compiler implementation
 (and any extensions it makes to the standard language), the language
 runtime environment, the basic library functions that make the language
 useful in practice, the operating system interface, add on sub-systems,
 and extra third party sub-systems and libraries.

 From the language standardiser's viewpoint, none of those, with the possible
 exception of the language implementation, and maybe its runtime, are part
 of "us", and none of the rest of it should be touching the reserved
 identifier space.

 From the point of view of the author of application programs, all of that
 stuff is part of the implementation (that is, everything that's on the
 system already when the application is about to be compiled) - the
 important point being that the application author is supposed to be able
 to use any identifiers he chooses, other than the reserved ones (which
 include the _X identifiers, and the various reserved words documented as
 part of the language, or as part of the documented interface of some other
 sub-system the application uses.)   But all those intermediate pieces also
 need to define hidden identifiers (like the names for the character classes
 in the libc ctype macros, ...) that are not part of the documented
 interface, yet still must not conflict with the application's identifier space.

 The only place all those system pieces (sys/*.h header files, libc
 header files, X11 header files, libcurses (etc) header files, linpng
 header files (etc)) can find to define identifiers that cannot bother
 a conforming application is the _X namespace.

 That's OK, as from the application viewpoint, which is the only one that
 really matters, all of that stuff is a part of the implementation.

 What that means is that it is entitled to use _X identifiers - and the "it"
 here is everything that's distributed with NetBSD (including pkgsrc), and
 thus it is never proper to complain about a violation of this particular
 rule anywhere in NetBSD.   So this PR should be closed and ignored.

 I suppose it could be argued that parts of NetBSD that can't be used by
 other applications (like the source code for cat, or ls or whatever)
 could be excluded from that, and if any of those things define _X type
 identifiers, that could be considered a bug.   But why would anyone care?
 As long as it works, it works, while making those programs portable to
 other systems would be nice, it isn't really a requirement, and within
 NetBSD, any such identifier (I doubt any exist, but they might I suppose)
 is clearly not causing a problem.   If it ever does due to changes elsewhere,
 it would get fixed pretty quickly.

 Of course, it is incumbent upon the implementation (that being NetBSD here)
 to make sure its use (throughout all parts of the implementation) of any
 of the identifiers from the implementation reserved space is all consistent,
 and safe - and if any of the sub-=parts of the implementation add new
 identifiers from this space, other parts may need to be updated to restore
 consistency, but that's OK, that's just a part of the system maintenance.

 kre

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: standards/46223: reserved identifier violation
Date: Sat, 14 Apr 2012 05:49:09 +0000

 On Fri, Apr 13, 2012 at 07:35:02PM +0000, Robert Elz wrote:
  >    |  I dare to point out open issues in the standard-compliant application
  >    |  of C/C++ naming conventions.
  >  
  >  Someone please close this PR - there cannot be a violation of this
  >  particular standards requirement in NetBSD - by definition.

 It is already closed.

 -- 
 David A. Holland
 dholland@netbsd.org

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.