From nobody@FreeBSD.ORG  Tue Jun  6 16:50:24 2000
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id DA31337BB9F; Tue,  6 Jun 2000 16:50:24 -0700 (PDT)
Message-Id: <20000606235024.DA31337BB9F@hub.freebsd.org>
Date: Tue,  6 Jun 2000 16:50:24 -0700 (PDT)
From: pfeifer@dbai.tuwien.ac.at
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@FreeBSD.org
Subject: #define trace _nc_trace in /usr/include/ncurses.h causes collateral damage.
X-Send-Pr-Version: www-1.0

>Number:         19077
>Category:       misc
>Synopsis:       #define trace _nc_trace in /usr/include/ncurses.h causes collateral damage.
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    peter
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 06 17:00:00 PDT 2000
>Closed-Date:    Mon Jul 10 19:35:36 PDT 2000
>Last-Modified:  Mon Jul 10 19:37:39 PDT 2000
>Originator:     Gerald Pfeifer
>Release:        n/a
>Organization:
Vienna University of Technology
>Environment:
n/a 
(Problem destilled from bug reports of 4.0-STABLE users and inspection)
>Description:
The following change to /usr/include/ncurses.h which adds a
  #define trace _nc_trace
causes problems with our Wine port and probably further software:

  1.1.1.3 (vendor branch) Wed May 24 10:44:45 2000 UTC by peter
  CVS Tags: v5_0_19991023, HEAD; Branch: NCURSES

  Bring in the fix for the trace/_nc_trace issue, without breaking the
  vendor branching.  The author has fixed this also so we can do this
  safely.

  1.1.1.2.2.1 Tue May 23 13:42:17 2000 UTC by ache
  Branch: RELENG_4

  MFC: trace -> _nc_trace

For example, consider the following snippet:

  void _nc_trace() { }
  #define trace _nc_trace

  main() {
   long trace=0;

   if( &trace != &_nc_trace )
       printf("Okay\n");
   }
   
As another example, consider Wine, where this change causes:

  ../libwine.so: undefined reference to `__GET_DEBUGGING__nc_trace'

  due to a new interaction with the TRACE macro in debugtools.h.

  http://cvs.winehq.com/cvsweb/wine/include/debugtools.h?rev=1.9 has
  the source of that Wine include file.

The new #define in ncurses.h clearly breaks ANSI/ISO C compliant code.



>How-To-Repeat:
Try the code snippet from "Full Description".
Compile the Wine port.
>Fix:
a. Remove that #define.
b. Adding a stub instead of that #define.

Andrey A. Chernov <ache@freebsd.org> who introduced the breakage cannot
install a fix by himself, but suggested the following:

--- include/curses.h.in.bak     Wed May 24 14:44:45 2000
+++ include/curses.h.in Mon Jun  5 02:28:33 2000
@@ -1313,8 +1313,7 @@
 extern char *_tracechtype(chtype);
 extern char *_tracechtype2(int, chtype);
 extern char *_tracemouse(const MEVENT *);
-#define trace _nc_trace
-extern void trace(const unsigned int);
+extern void _nc_trace(const unsigned int);
 
 /* trace masks */
 #define TRACE_DISABLE  0x0000  /* turn off tracing */


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: will 
State-Changed-When: Tue Jun 6 19:39:23 PDT 2000 
State-Changed-Why:  
I'm making this Peter's problem until it is fixed in the 
tree.  Right now, I can't build WINE because of this, and 
because a WINE PR is assigned to me, this does not make me 
happy.  Please fix this as soon as you can!  ;-) 


Responsible-Changed-From-To: freebsd-bugs->peter 
Responsible-Changed-By: will 
Responsible-Changed-When: Tue Jun 6 19:39:23 PDT 2000 
Responsible-Changed-Why:  
Peter's the one who imported "proper fix" to 5.0-CURRENT. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=19077 

From: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To: pfeifer@dbai.tuwien.ac.at
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: misc/19077: #define trace _nc_trace in /usr/include/ncurses.h causes collateral damage.
Date: Wed, 7 Jun 2000 17:09:49 -0400 (EDT)

 <<On Tue,  6 Jun 2000 16:50:24 -0700 (PDT), pfeifer@dbai.tuwien.ac.at said:
 
 > The new #define in ncurses.h clearly breaks ANSI/ISO C compliant code.
 
 <ncurses.h> is not an ANSI/ISO C header.
 
 -GAWollman
 

From: Bruce Evans <bde@zeta.org.au>
To: pfeifer@dbai.tuwien.ac.at
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: misc/19077: #define trace _nc_trace in /usr/include/ncurses.h
 causes collateral damage.
Date: Thu, 8 Jun 2000 22:03:18 +1000 (EST)

 > The new #define in ncurses.h clearly breaks ANSI/ISO C compliant code.
 
 It's clearly wrong (#define's are much more namespace-polluting than
 extern variables an functions, as this example shows), but doesn't
 break Standard C code any more than just including a nonStandard header
 like <ncurses.h>.
 
 Bruce
 
 

From: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
To: Bruce Evans <bde@zeta.org.au>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: misc/19077: #define trace _nc_trace in /usr/include/ncurses.h
 causes collateral damage.
Date: Thu, 8 Jun 2000 15:27:49 +0200 (MET DST)

 On Thu, 8 Jun 2000, Bruce Evans wrote:
 >> The new #define in ncurses.h clearly breaks ANSI/ISO C compliant code.
 > It's clearly wrong (#define's are much more namespace-polluting than
 > extern variables an functions, as this example shows), but doesn't
 > break Standard C code any more than just including a nonStandard header
 > like <ncurses.h>.
 
 Yes, you're right. What I ment was that code which is ANSI/ISO C
 compliant apart from #including system headers breaks.
 
 Problem is, two people now pointed out that detail in my PR, but none
 attacked the real problem! :-(
 
 Gerald
 -- 
 Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/
 
 
State-Changed-From-To: feedback->closed 
State-Changed-By: nrahlstr 
State-Changed-When: Mon Jul 10 19:35:36 PDT 2000 
State-Changed-Why:  
Fixed by peter's import of ncurses 5.1 prerelease (20000701). 
Paul MFC'ed this to -stable. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=19077 
>Unformatted:
