Subject: pkg/23330: devel/netcdf doesn't compile in current (gcc3 issues)
To: None <gnats-bugs@gnats.netbsd.org>
From: None <wolfgang@wsrcc.com>
List: netbsd-bugs
Date: 10/31/2003 19:34:41
>Number:         23330
>Category:       pkg
>Synopsis:       devel/netcdf doesn't compile in current (gcc3 issues)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Nov 01 03:35:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Wolfgang S. Rupprecht
>Release:        NetBSD 1.6ZE
>Organization:
W S Rupprecht Computer Consulting, Fremont CA
>Environment:
	
	
System: NetBSD capsicum.wsrcc.com 1.6ZE NetBSD 1.6ZE (WSRCC_ATHLON) #4: Fri Oct 31 11:59:43 PST 2003 wolfgang@capsicum.wsrcc.com:/var/obj/netbsd/sys/arch/i386/compile/WSRCC_ATHLON i386
Architecture: i386
Machine: i386
>Description:

	/usr/pkgsrc/devel/netcdf doesn't compile in -current due to
	gcc3 issues.

	apologies if this isn't at the right severity/priority level.

>How-To-Repeat:
	cd /usr/pkgsrc/devel/netcdf ; make 
>Fix:
	
	I stole the patches from Mike Romberg (NOAA/FSL).
	Search for "gcc-3.0":
	http://www.unidata.ucar.edu/packages/netcdf/known_problems.html 

Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/devel/netcdf/distinfo,v
retrieving revision 1.7
diff -u -r1.7 distinfo
--- distinfo	2003/10/26 14:05:59	1.7
+++ distinfo	2003/11/01 03:27:14
@@ -12,3 +12,8 @@
 SHA1 (patch-ai) = fb8386c47a2b0e2468bf31a424738979c472de94
 SHA1 (patch-aj) = beff85a29fa6407bde19bc2061b2082b4b5cb5d1
 SHA1 (patch-ak) = 7378c3ce65bb639051c385885e3a1d186514f697
+SHA1 (patch-al) = c58dacd2f4ad24e8c9d1ef880cac6bc03d7b4293
+SHA1 (patch-am) = ddc532078c5167ec8fc097d2c20a1311c74848f6
+SHA1 (patch-an) = 6c6b5e24592b2c991a2e48167d52785ec3a9ba5c
+SHA1 (patch-ao) = acb6b6bd2bf8a945bca6bbeb9d792a7175b84386
+SHA1 (patch-ap) = ca6b384b4fcd10bf4fd76b01c8624af328200908
--- /dev/null	2003-10-31 19:21:54.000000000 -0800
+++ patches/patch-al	2003-10-31 19:20:05.000000000 -0800
@@ -0,0 +1,40 @@
+*** netcdf-3.5.0.orig/src/aclocal.m4	Thu Mar 22 14:43:11 2001
+--- aclocal.m4	Thu Aug 15 15:57:08 2002
+***************
+*** 173,181 ****
+  			AC_MSG_CHECKING(C++ compiler \"$CXX\")
+  			AC_TRY_RUN(
+   			    [
+! 				#include <iostream.h>
+  				int main() {
+! 				    cout << "";
+  				    return 0;
+  				}
+  			    ],
+--- 173,181 ----
+  			AC_MSG_CHECKING(C++ compiler \"$CXX\")
+  			AC_TRY_RUN(
+   			    [
+! 				#include <iostream>
+  				int main() {
+! 				    std::cout << "";
+  				    return 0;
+  				}
+  			    ],
+***************
+*** 1141,1147 ****
+      echo "running [\$]{CONFIG_SHELL-/bin/sh} [$]0 [$]ac_configure_args --no-create --no-recursion"
+      exec [\$]{CONFIG_SHELL-/bin/sh} [$]0 [$]ac_configure_args --no-create --no-recursion ;;
+    -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+!     echo "$CONFIG_STATUS generated by autoconf version AC_ACVERSION"
+      exit 0 ;;
+    -help | --help | --hel | --he | --h)
+      echo "[\$]ac_cs_usage"; exit 0 ;;
+--- 1141,1147 ----
+      echo "running [\$]{CONFIG_SHELL-/bin/sh} [$]0 [$]ac_configure_args --no-create --no-recursion"
+      exec [\$]{CONFIG_SHELL-/bin/sh} [$]0 [$]ac_configure_args --no-create --no-recursion ;;
+    -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+!     echo "$CONFIG_STATUS generated by autoconf version ?unknown?"
+      exit 0 ;;
+    -help | --help | --hel | --he | --h)
+      echo "[\$]ac_cs_usage"; exit 0 ;;
--- /dev/null	2003-10-31 19:21:54.000000000 -0800
+++ patches/patch-am	2003-10-31 19:20:11.000000000 -0800
@@ -0,0 +1,44 @@
+*** netcdf-3.5.0.orig/src/configure.in	Thu Mar 22 14:43:13 2001
+--- configure.in	Thu Aug 15 14:51:17 2002
+***************
+*** 3,15 ****
+  dnl Process this file with GNU autoconf(1) to produce a configure script.
+  dnl
+  
+  dnl Defaults:
+  CPPFLAGS=${CPPFLAGS--DNDEBUG}
+  CFLAGS=${CFLAGS--O}
+  FPPFLAGS=${FPPFLAGS-}
+  FFLAGS=${FFLAGS-}
+- 
+- AC_INIT(libsrc/ncconfig.in)
+  UD_SRCDIR
+  AC_PREFIX_DEFAULT(`(cd ..; pwd)`)
+  AC_CONFIG_HEADER(
+--- 3,17 ----
+  dnl Process this file with GNU autoconf(1) to produce a configure script.
+  dnl
+  
++ AC_INIT(netcdf, 3.5.0)
++ dnl AC_INIT(libsrc/ncconfig.in)
++ 
++ 
+  dnl Defaults:
+  CPPFLAGS=${CPPFLAGS--DNDEBUG}
+  CFLAGS=${CFLAGS--O}
+  FPPFLAGS=${FPPFLAGS-}
+  FFLAGS=${FFLAGS-}
+  UD_SRCDIR
+  AC_PREFIX_DEFAULT(`(cd ..; pwd)`)
+  AC_CONFIG_HEADER(
+***************
+*** 55,58 ****
+  UD_CHECK_SIZEOF(size_t)
+  UD_MAKEWHATIS
+  UD_FTPBINDIR
+! UD_OUTPUT(macros.make)
+--- 57,60 ----
+  UD_CHECK_SIZEOF(size_t)
+  UD_MAKEWHATIS
+  UD_FTPBINDIR
+! AC_OUTPUT(macros.make)
--- /dev/null	2003-10-31 19:21:54.000000000 -0800
+++ patches/patch-an	2003-10-31 19:20:16.000000000 -0800
@@ -0,0 +1,222 @@
+*** netcdf-3.5.0.orig/src/cxx/nctst.cpp	Fri Sep 17 11:21:23 1999
+--- cxx/nctst.cpp	Thu Aug 15 15:40:14 2002
+***************
+*** 1,4 ****
+! #include <iostream.h>
+  #include <string.h>
+  #include "netcdfcpp.h"
+  
+--- 1,4 ----
+! #include <iostream>
+  #include <string.h>
+  #include "netcdfcpp.h"
+  
+***************
+*** 8,14 ****
+  
+      // Check if the file was opened successfully
+      if (! nc.is_valid()) {
+! 	cerr << "can't create netCDF file " << path << "\n";
+  	return;
+      }
+  
+--- 8,14 ----
+  
+      // Check if the file was opened successfully
+      if (! nc.is_valid()) {
+! 	std::cerr << "can't create netCDF file " << path << "\n";
+  	return;
+      }
+  
+***************
+*** 124,135 ****
+  
+      for (int n=0; n < num_dims(); n++) {
+  	NcDim* dim = get_dim(n);
+! 	cout << "\t" << dim->name() << " = " ;
+  	if (dim->is_unlimited())
+! 	  cout << "UNLIMITED" << " ;\t " << "// " << dim->size() <<
+  	    " currently\n";
+  	else
+! 	  cout << dim->size() << " ;\n";
+      }
+  }
+  
+--- 124,135 ----
+  
+      for (int n=0; n < num_dims(); n++) {
+  	NcDim* dim = get_dim(n);
+! 	std::cout << "\t" << dim->name() << " = " ;
+  	if (dim->is_unlimited())
+! 	  std::cout << "UNLIMITED" << " ;\t " << "// " << dim->size() <<
+  	    " currently\n";
+  	else
+! 	  std::cout << dim->size() << " ;\n";
+      }
+  }
+  
+***************
+*** 137,146 ****
+  {
+      NcToken vname = var.name();
+      NcAtt* ap;
+!     for(int n = 0; ap = var.get_att(n); n++) {
+! 	cout << "\t\t" << vname << ":" << ap->name() << " = " ;
+  	NcValues* vals = ap->values();
+! 	cout << *vals << " ;" << endl ;
+  	delete ap;
+  	delete vals;
+      }
+--- 137,146 ----
+  {
+      NcToken vname = var.name();
+      NcAtt* ap;
+!     for(int n = 0; (ap = var.get_att(n)); n++) {
+! 	std::cout << "\t\t" << vname << ":" << ap->name() << " = " ;
+  	NcValues* vals = ap->values();
+! 	std::cout << *vals << " ;" << std::endl ;
+  	delete ap;
+  	delete vals;
+      }
+***************
+*** 153,172 ****
+        {"","byte","char","short","long","float","double"};
+      NcVar* vp;
+  
+!     for(n = 0; vp = get_var(n); n++) {
+! 	cout << "\t" << types[vp->type()] << " " << vp->name() ;
+  
+  	if (vp->num_dims() > 0) {
+! 	    cout << "(";
+  	    for (int d = 0; d < vp->num_dims(); d++) {
+  		NcDim* dim = vp->get_dim(d);
+! 		cout << dim->name();
+  		if (d < vp->num_dims()-1)
+! 		  cout << ", ";		  
+  	    }
+! 	    cout << ")";
+  	}
+! 	cout << " ;\n";
+  	// now dump each of this variable's attributes
+  	dumpatts(*vp);
+      }
+--- 153,172 ----
+        {"","byte","char","short","long","float","double"};
+      NcVar* vp;
+  
+!     for(n = 0; (vp = get_var(n)); n++) {
+! 	std::cout << "\t" << types[vp->type()] << " " << vp->name() ;
+  
+  	if (vp->num_dims() > 0) {
+! 	    std::cout << "(";
+  	    for (int d = 0; d < vp->num_dims(); d++) {
+  		NcDim* dim = vp->get_dim(d);
+! 		std::cout << dim->name();
+  		if (d < vp->num_dims()-1)
+! 		  std::cout << ", ";
+  	    }
+! 	    std::cout << ")";
+  	}
+! 	std::cout << " ;\n";
+  	// now dump each of this variable's attributes
+  	dumpatts(*vp);
+      }
+***************
+*** 175,184 ****
+  void DumpableNcFile::dumpgatts( void )
+  {
+      NcAtt* ap;
+!     for(int n = 0; ap = get_att(n); n++) {
+! 	cout << "\t\t" << ":" << ap->name() << " = " ;
+  	NcValues* vals = ap->values();
+! 	cout << *vals << " ;" << endl ;
+  	delete vals;
+  	delete ap;
+      }
+--- 175,184 ----
+  void DumpableNcFile::dumpgatts( void )
+  {
+      NcAtt* ap;
+!     for(int n = 0; (ap = get_att(n)); n++) {
+! 	std::cout << "\t\t" << ":" << ap->name() << " = " ;
+  	NcValues* vals = ap->values();
+! 	std::cout << *vals << " ;" << std::endl ;
+  	delete vals;
+  	delete ap;
+      }
+***************
+*** 187,196 ****
+  void DumpableNcFile::dumpdata( )
+  {
+      NcVar* vp;
+!     for (int n = 0; vp = get_var(n); n++) {
+! 	cout << " " << vp->name() << " = ";
+  	NcValues* vals = vp->values();
+! 	cout << *vals << " ;" << endl ;
+  	delete vals;
+      }
+  }
+--- 187,196 ----
+  void DumpableNcFile::dumpdata( )
+  {
+      NcVar* vp;
+!     for (int n = 0; (vp = get_var(n)); n++) {
+! 	std::cout << " " << vp->name() << " = ";
+  	NcValues* vals = vp->values();
+! 	std::cout << *vals << " ;" << std::endl ;
+  	delete vals;
+      }
+  }
+***************
+*** 199,223 ****
+  {
+      DumpableNcFile nc(path);	// default is open in read-only mode
+  
+!     cout << "netcdf " << cdl_name(path) << " {" << endl <<
+! 	    "dimensions:" << endl ;
+  
+      nc.dumpdims();
+  
+!     cout << "variables:" << endl;
+  
+      nc.dumpvars();
+  
+      if (nc.num_atts() > 0)
+!       cout << "// global attributes" << endl ;
+  
+      nc.dumpgatts();
+  
+!     cout << "data:" << endl;
+  
+      nc.dumpdata();
+  
+!     cout << "}" << endl;
+  }
+  
+  
+--- 199,223 ----
+  {
+      DumpableNcFile nc(path);	// default is open in read-only mode
+  
+!     std::cout << "netcdf " << cdl_name(path) << " {" << std::endl <<
+! 	    "dimensions:" << std::endl ;
+  
+      nc.dumpdims();
+  
+!     std::cout << "variables:" << std::endl;
+  
+      nc.dumpvars();
+  
+      if (nc.num_atts() > 0)
+!       std::cout << "// global attributes" << std::endl ;
+  
+      nc.dumpgatts();
+  
+!     std::cout << "data:" << std::endl;
+  
+      nc.dumpdata();
+  
+!     std::cout << "}" << std::endl;
+  }
+  
+  
--- /dev/null	2003-10-31 19:21:54.000000000 -0800
+++ patches/patch-ao	2003-10-31 19:20:22.000000000 -0800
@@ -0,0 +1,180 @@
+*** netcdf-3.5.0.orig/src/cxx/ncvalues.cpp	Tue Dec 22 11:21:49 1998
+--- cxx/ncvalues.cpp	Thu Aug 15 15:36:06 2002
+***************
+*** 7,13 ****
+   *   $Header: /upc/share/CVS/netcdf-3/cxx/ncvalues.cpp,v 1.3 1998/12/22 18:21:49 russ Exp $
+   *********************************************************************/
+  
+! #include <iostream.h>		// for debugging
+  #include "ncvalues.h"
+  
+  NcValues::NcValues( void ) : the_number(0), the_type(ncNoType)
+--- 7,13 ----
+   *   $Header: /upc/share/CVS/netcdf-3/cxx/ncvalues.cpp,v 1.3 1998/12/22 18:21:49 russ Exp $
+   *********************************************************************/
+  
+! #include <iostream>		// for debugging
+  #include "ncvalues.h"
+  
+  NcValues::NcValues( void ) : the_number(0), the_type(ncNoType)
+***************
+*** 25,31 ****
+      return the_number;
+  }    
+  
+! ostream& operator<< (ostream& os, const NcValues& vals)
+  {
+      return vals.print(os);
+  }
+--- 25,31 ----
+      return the_number;
+  }
+  
+! std::ostream& operator<< (std::ostream& os, const NcValues& vals)
+  {
+      return vals.print(os);
+  }
+***************
+*** 244,250 ****
+      return s;
+  }
+  
+! ostream& NcValues_short::print(ostream& os) const
+  {
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+--- 244,250 ----
+      return s;
+  }
+  
+! std::ostream& NcValues_short::print(std::ostream& os) const
+  {
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+***************
+*** 253,259 ****
+      return os;
+  }
+  
+! ostream& NcValues_int::print(ostream& os) const
+  {
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+--- 253,259 ----
+      return os;
+  }
+  
+! std::ostream& NcValues_int::print(std::ostream& os) const
+  {
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+***************
+*** 262,268 ****
+      return os;
+  }
+  
+! ostream& NcValues_nclong::print(ostream& os) const
+  {
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+--- 262,268 ----
+      return os;
+  }
+  
+! std::ostream& NcValues_nclong::print(std::ostream& os) const
+  {
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+***************
+*** 271,277 ****
+      return os;
+  }
+  
+! ostream& NcValues_long::print(ostream& os) const
+  {
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+--- 271,277 ----
+      return os;
+  }
+  
+! std::ostream& NcValues_long::print(std::ostream& os) const
+  {
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+***************
+*** 280,286 ****
+      return os;
+  }
+  
+! ostream& NcValues_ncbyte::print(ostream& os) const
+  {
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+--- 280,286 ----
+      return os;
+  }
+  
+! std::ostream& NcValues_ncbyte::print(std::ostream& os) const
+  {
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+***************
+*** 289,295 ****
+      return os;
+  }
+  
+! ostream& NcValues_char::print(ostream& os) const
+  {
+      os << '"';
+      long len = the_number;
+--- 289,295 ----
+      return os;
+  }
+  
+! std::ostream& NcValues_char::print(std::ostream& os) const
+  {
+      os << '"';
+      long len = the_number;
+***************
+*** 302,310 ****
+      return os;
+  }
+  
+! ostream& NcValues_float::print(ostream& os) const
+  {
+!     long save=os.flags();
+      os.precision(7);
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+--- 302,310 ----
+      return os;
+  }
+  
+! std::ostream& NcValues_float::print(std::ostream& os) const
+  {
+!     std::ostream::fmtflags save=os.flags();
+      os.precision(7);
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+***************
+*** 314,322 ****
+      return os;
+  }
+  
+! ostream& NcValues_double::print(ostream& os) const
+  {
+!     long save=os.flags();
+      os.precision(15);
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
+--- 314,322 ----
+      return os;
+  }
+  
+! std::ostream& NcValues_double::print(std::ostream& os) const
+  {
+!     std::ostream::fmtflags save=os.flags();
+      os.precision(15);
+      for(int i = 0; i < the_number - 1; i++)
+        os << the_values[i] << ", ";
--- /dev/null	2003-10-31 19:21:54.000000000 -0800
+++ patches/patch-ap	2003-10-31 19:20:27.000000000 -0800
@@ -0,0 +1,105 @@
+*** netcdf-3.5.0.orig/src/cxx/ncvalues.h	Wed Oct 28 10:10:16 1998
+--- cxx/ncvalues.h	Thu Aug 15 15:33:41 2002
+***************
+*** 10,20 ****
+  #ifndef Ncvalues_def
+  #define Ncvalues_def
+  
+! #include <iostream.h>
+  #ifdef STRSTREAM_H_SPEC
+  #   include STRSTREAM_H_SPEC
+  #else
+! #   include <strstream.h>
+  #endif
+  #include <limits.h>
+  #include <string.h>
+--- 10,20 ----
+  #ifndef Ncvalues_def
+  #define Ncvalues_def
+  
+! #include <iostream>
+  #ifdef STRSTREAM_H_SPEC
+  #   include STRSTREAM_H_SPEC
+  #else
+! #   include <sstream>
+  #endif
+  #include <limits.h>
+  #include <string.h>
+***************
+*** 82,88 ****
+      virtual int invalid( void ) const;					      \
+    private:								      \
+      TYPE* the_values;							      \
+!     ostream& print(ostream&) const;					      \
+  };
+  
+  #define NcTypeEnum(TYPE) makename2(_nc__,TYPE)
+--- 82,88 ----
+      virtual int invalid( void ) const;					      \
+    private:								      \
+      TYPE* the_values;							      \
+!     std::ostream& print(std::ostream&) const;	         		      \
+  };
+  
+  #define NcTypeEnum(TYPE) makename2(_nc__,TYPE)
+***************
+*** 219,227 ****
+  #define as_string_implement(TYPE)					      \
+  char* NcVal(TYPE)::as_string( long n ) const				      \
+  {									      \
+!     char* s = new char[32];						      \
+!     ostrstream ostr(s, sizeof(s));                                            \
+!     ostr << the_values[n] << ends;              			      \
+      return s;								      \
+  }
+  
+--- 219,229 ----
+  #define as_string_implement(TYPE)					      \
+  char* NcVal(TYPE)::as_string( long n ) const				      \
+  {									      \
+!     std::ostringstream ostr;                                                  \
+!     ostr << the_values[n] << std::ends;              			      \
+!     std::string str(ostr.str());                                              \
+!     char *s = new char[str.size()];                                           \
+!     str.copy(s, str.size());                                                  \
+      return s;           						      \
+  }
+  
+***************
+*** 232,238 ****
+      NcValues(NcType, long);
+      virtual ~NcValues( void );
+      virtual long num( void );
+!     virtual ostream& print(ostream&) const = 0;
+      virtual void* base( void ) const = 0;
+      virtual int bytes_for_one( void ) const = 0;
+  
+--- 234,240 ----
+      NcValues(NcType, long);
+      virtual ~NcValues( void );
+      virtual long num( void );
+!     virtual std::ostream& print(std::ostream&) const = 0;
+      virtual void* base( void ) const = 0;
+      virtual int bytes_for_one( void ) const = 0;
+  
+***************
+*** 250,258 ****
+      virtual char* as_string( long n ) const = 0;  // value as string
+      
+    protected:
+-     NcType the_type;
+      long the_number;
+!     friend ostream& operator<< (ostream&, const NcValues&);
+  };
+  
+  declare(NcValues,ncbyte)
+--- 252,260 ----
+      virtual char* as_string( long n ) const = 0;  // value as string
+  
+    protected:
+      long the_number;
+!     NcType the_type;
+!     friend std::ostream& operator<< (std::ostream&, const NcValues&);
+  };
+  
+  declare(NcValues,ncbyte)
>Release-Note:
>Audit-Trail:
>Unformatted: