public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/5350: Problems with valarrays (struct members are private)
@ 2002-01-10 7:46 Peter Schmid
0 siblings, 0 replies; 2+ messages in thread
From: Peter Schmid @ 2002-01-10 7:46 UTC (permalink / raw)
To: gcc-gnats
>Number: 5350
>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 07:46:04 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] 2+ messages in thread
* Re: c++/5350: Problems with valarrays (struct members are private)
@ 2002-01-10 13:42 paolo
0 siblings, 0 replies; 2+ messages in thread
From: paolo @ 2002-01-10 13:42 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, nobody, schmid
Synopsis: Problems with valarrays (struct members are private)
State-Changed-From-To: open->closed
State-Changed-By: paolo
State-Changed-When: Thu Jan 10 13:42:04 2002
State-Changed-Why:
Identical to PR5348
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5350
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-01-10 21:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-10 7:46 c++/5350: Problems with valarrays (struct members are private) Peter Schmid
2002-01-10 13:42 paolo
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).