public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/5348: Problems with valarrays (struct members are private)
@ 2002-01-17 15:03 bkoz
  0 siblings, 0 replies; 5+ messages in thread
From: bkoz @ 2002-01-17 15:03 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, nathan, nobody, peter

Synopsis: Problems with valarrays (struct members are private)

Responsible-Changed-From-To: unassigned->nathan
Responsible-Changed-By: bkoz
Responsible-Changed-When: Thu Jan 17 15:03:48 2002
Responsible-Changed-Why:
    Nathan can you please look at this? This is causing 2 extra fails for libstdc++-v3, for over a week. 

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5348


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: c++/5348: Problems with valarrays (struct members are private)
@ 2002-01-19 12:56 nathan
  0 siblings, 0 replies; 5+ messages in thread
From: nathan @ 2002-01-19 12:56 UTC (permalink / raw)
  To: bkoz, david.billinghurst, gcc-bugs, gcc-prs, nathan, peter

Synopsis: Problems with valarrays (struct members are private)

State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Sat Jan 19 12:56:33 2002
State-Changed-Why:
    2002-01-19  Nathan Sidwell  <nathan@codesourcery.com>
    
    	Fix regression introduced with patch for c++/775
    	* parse.y (class_head_defn): Check for template specializations
    	with a different class-key.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5348


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: c++/5348: Problems with valarrays (struct members are private)
@ 2002-01-18  1:46 Nathan Sidwell
  0 siblings, 0 replies; 5+ messages in thread
From: Nathan Sidwell @ 2002-01-18  1:46 UTC (permalink / raw)
  To: nathan; +Cc: gcc-prs

The following reply was made to PR c++/5348; it has been noted by GNATS.

From: Nathan Sidwell <nathan@acm.org>
To: bkoz@gcc.gnu.org, bkoz@redhat.com, gcc-bugs@gcc.gnu.org, 
    gcc-prs@gcc.gnu.org, nathan@gcc.gnu.org, nobody@gcc.gnu.org, 
    peter@snake.iap.physik.tu-darmstadt.de, gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/5348: Problems with valarrays (struct members are private)
Date: Fri, 18 Jan 2002 09:36:36 +0000

 bkoz@gcc.gnu.org wrote:
 
 I intend to get to it this weekend.
 
 nathan
 -- 
 Dr Nathan Sidwell :: Computer Science Department :: Bristol University
            The voices in my head told me to say this
 nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: c++/5348: Problems with valarrays (struct members are private)
@ 2002-01-11 14:16 Paolo Carlini
  0 siblings, 0 replies; 5+ messages in thread
From: Paolo Carlini @ 2002-01-11 14:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/5348; it has been noted by GNATS.

From: Paolo Carlini <pcarlini@unitus.it>
To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
 	nobody@gcc.gnu.org, peter@snake.iap.physik.tu-darmstadt.de
Cc:  
Subject: Re: c++/5348: Problems with valarrays (struct members are private)
Date: Fri, 11 Jan 2002 23:10:04 +0100

 The testcase can be reduced to:
 
 //////////////////
 template<typename _Type1, typename _Type2>
 class _Bin;
 
 template<typename _Type1>
 struct _Bin<_Type1, double>
 {
   _Bin () {}
 };
 
 _Bin<double, double> a;
 //////////////////
 
 Surprisingly, the following is ok:
 
 /////////////////
 template<typename _Type1, typename _Type2>
 class _Bin;
 
 template<typename _Type1>
 class _Bin<_Type1, double>
 {
 public:
   _Bin () {}
 };
 
 _Bin<double, double> a;
 ////////////////////
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5348
 
 
 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* c++/5348: Problems with valarrays (struct members are private)
@ 2002-01-10  5:36 peter
  0 siblings, 0 replies; 5+ messages in thread
From: peter @ 2002-01-10  5:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         5348
>Category:       c++
>Synopsis:       Problems with valarrays (struct members are private)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 10 05:36:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Peter Schmid
>Release:        3.1 20020108 (experimental)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.17 #7 Thu Jan 3 17:21:51 CET 2002 i686 unknown
Architecture: i686
linux 2.4.17
glibc 2.2.4 + patches
GNU ld version 2.11.92.0.12.3 20011121
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads --enable-languages=c,c++,f77,objc
>Description:
Valarrays do not compile on the mainline. That is because of a compiler
bug. The compiler treats the members of the
_BinClos<_Oper,_ValArray,_Constant,_Tp,_Tp> struct as private in
contrast to the standard. If this struct is written as a class with a  
public label gcc accepts tv2.C without a warning.
>How-To-Repeat:
source code tv2.C

namespace std
{
#define size_t unsigned long  

template <class _Arg1, class _Arg2, class _Result>
struct binary_function {
  typedef _Arg1 first_argument_type;  
  typedef _Arg2 second_argument_type;
  typedef _Result result_type;        
};      

template <class _Tp>
struct plus : public binary_function<_Tp,_Tp,_Tp> {
  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; }
};
    
template<class _Clos, typename _Tp> class _Expr;

    template<typename _Tp1, typename _Tp2> class _ValArray;    

    template<template<class> class _Oper,
        template<class, class> class _Meta, class _Dom> struct _UnClos;

    template<template<class> class _Oper,
        template<class, class> class _Meta1,
        template<class, class> class _Meta2,
        class _Dom1, class _Dom2> class _BinClos;

    template<class _Tp> struct _Unary_plus;
  
    template<class _Tp> class valarray;   // An array of type _Tp

    template<typename _Tp> struct _Array {};
    template<typename _Tp1, typename _Tp2> class _Constant;
    
    template<template<class> class _Oper, class _Clos>
    class _BinBase2 {
    public:
        typedef typename _Clos::value_type _Vt;
        typedef _Oper<_Vt> _Op;
        typedef typename _Op::result_type value_type;

        _BinBase2 (const _Clos& __e, const _Vt& __t)
                : _M_expr1 (__e), _M_expr2 (__t) {}
        value_type operator[] (size_t) const;
        size_t size () const { return _M_expr1.size (); }

    private:
        const _Clos& _M_expr1;
        const _Vt& _M_expr2;
    };

    template<template<class> class _Oper, class _Clos>
    inline typename _BinBase2<_Oper,_Clos>::value_type
    _BinBase2<_Oper,_Clos>::operator[] (size_t __i) const
    { return _Op() (_M_expr1[__i], _M_expr2); }
    
    template<template<class> class _Oper, typename _Tp>
    struct _BinClos<_Oper,_ValArray,_Constant,_Tp,_Tp>
        : _BinBase2<_Oper,valarray<_Tp> > {
        typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
        typedef typename _Base::value_type value_type;

        _BinClos (const valarray<_Tp>& __v, const _Tp& __t)
                : _Base (__v, __t) {}
    };

    template<class _Clos, typename _Tp> class _Expr {
    public:
      _Expr (const _Clos&);
    };

  template<class _Tp> class valarray
  {
  public:
      typedef _Tp value_type;
      valarray();
      explicit valarray(size_t);
      template<class _Dom>
      valarray(const _Expr<_Dom,_Tp>& __e);
  };

#define _DEFINE_BINARY_OPERATOR(_Op, _Name)				\
									\
  template<typename _Tp>						\
  inline _Expr<_BinClos<_Name,_ValArray,_Constant,_Tp,_Tp>,_Tp>         \
  operator _Op (const valarray<_Tp> &__v, const _Tp &__t)		\
  {									\
      typedef _BinClos<_Name,_ValArray,_Constant,_Tp,_Tp> _Closure;	\
      return _Expr<_Closure, _Tp> (_Closure (__v, __t));	        \
  }									\

_DEFINE_BINARY_OPERATOR(+, plus)

#undef _DEFINE_BINARY_OPERATOR

} // namespace std

using namespace std;

int main()
{
    valarray<double> va(9);
    valarray<double> vb(va+10.0);
}

g++ -v tv2.C -W -Wall --save-temps
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads --enable-languages=c,c++,f77,objc
Thread model: posix
gcc version 3.1 20020108 (experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cpp0 -lang-c++ -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -W -Wall -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tv2.C tv2.ii
GNU CPP version 3.1 20020108 (experimental) (cpplib) (i386 Linux/ELF)
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/include/g++-v3/i686-pc-linux-gnu
 /usr/local/include/g++-v3/backward
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1plus -fpreprocessed tv2.ii -quiet -dumpbase tv2.C -W -Wall -version -o tv2.s
GNU CPP version 3.1 20020108 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.1 20020108 (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 3.1 20020108 (experimental).
tv2.C: In function `int main()':
tv2.C:104: warning: unused variable `std::valarray<double> vb'
tv2.C: In function `std::_Expr<std::_BinClos<std::plus, std::_ValArray, 
   std::_Constant, _Tp, _Tp>, _Tp> std::operator+(const std::valarray<_Tp>&, 
   const _Tp&) [with _Tp = double]':
tv2.C:104:   instantiated from here
tv2.C:65: `std::_BinClos<_Oper, std::_ValArray, std::_Constant, _Tp, 
   _Tp>::_BinClos(const std::valarray<_Tp>&, const _Tp&) [with _Oper = 
   std::plus, _Tp = double]' is private
tv2.C:93: within this context

preprocessed source code tv2.ii
# 1 "tv2.C"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "tv2.C"
namespace std
{


template <class _Arg1, class _Arg2, class _Result>
struct binary_function {
  typedef _Arg1 first_argument_type;
  typedef _Arg2 second_argument_type;
  typedef _Result result_type;
};

template <class _Tp>
struct plus : public binary_function<_Tp,_Tp,_Tp> {
  _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; }
};

template<class _Clos, typename _Tp> class _Expr;

    template<typename _Tp1, typename _Tp2> class _ValArray;

    template<template<class> class _Oper,
        template<class, class> class _Meta, class _Dom> struct _UnClos;

    template<template<class> class _Oper,
        template<class, class> class _Meta1,
        template<class, class> class _Meta2,
        class _Dom1, class _Dom2> class _BinClos;

    template<class _Tp> struct _Unary_plus;

    template<class _Tp> class valarray;

    template<typename _Tp> struct _Array {};
    template<typename _Tp1, typename _Tp2> class _Constant;

    template<template<class> class _Oper, class _Clos>
    class _BinBase2 {
    public:
        typedef typename _Clos::value_type _Vt;
        typedef _Oper<_Vt> _Op;
        typedef typename _Op::result_type value_type;

        _BinBase2 (const _Clos& __e, const _Vt& __t)
                : _M_expr1 (__e), _M_expr2 (__t) {}
        value_type operator[] (unsigned long) const;
        unsigned long size () const { return _M_expr1.size (); }

    private:
        const _Clos& _M_expr1;
        const _Vt& _M_expr2;
    };

    template<template<class> class _Oper, class _Clos>
    inline typename _BinBase2<_Oper,_Clos>::value_type
    _BinBase2<_Oper,_Clos>::operator[] (unsigned long __i) const
    { return _Op() (_M_expr1[__i], _M_expr2); }

    template<template<class> class _Oper, typename _Tp>
    struct _BinClos<_Oper,_ValArray,_Constant,_Tp,_Tp>
        : _BinBase2<_Oper,valarray<_Tp> > {
        typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
        typedef typename _Base::value_type value_type;

        _BinClos (const valarray<_Tp>& __v, const _Tp& __t)
                : _Base (__v, __t) {}
    };

    template<class _Clos, typename _Tp> class _Expr {
    public:
      _Expr (const _Clos&);
    };

  template<class _Tp> class valarray
  {
  public:
      typedef _Tp value_type;
      valarray();
      explicit valarray(unsigned long);
      template<class _Dom>
      valarray(const _Expr<_Dom,_Tp>& __e);
  };
# 93 "tv2.C"
template<typename _Tp> inline _Expr<_BinClos<plus,_ValArray,_Constant,_Tp,_Tp>,_Tp> operator + (const valarray<_Tp> &__v, const _Tp &__t) { typedef _BinClos<plus,_ValArray,_Constant,_Tp,_Tp> _Closure; return _Expr<_Closure, _Tp> (_Closure (__v, __t)); }



}

using namespace std;

int main()
{
    valarray<double> va(9);
    valarray<double> vb(va+10.0);
}

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-01-19 20:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-17 15:03 c++/5348: Problems with valarrays (struct members are private) bkoz
  -- strict thread matches above, loose matches on Subject: below --
2002-01-19 12:56 nathan
2002-01-18  1:46 Nathan Sidwell
2002-01-11 14:16 Paolo Carlini
2002-01-10  5:36 peter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).