https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69116

            Bug ID: 69116
           Summary: compile error when including valarray
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gnu at gonsoe dot com
  Target Milestone: ---

The following code does not compile with gcc4.8.4 or gcc5.2.1.  I have access
to an older 4.8.0 compiler where the code compiles ok, so this appears to be a
regression.  

The inclusion of <valarray> causes the compile error.

#include <ostream>
#include <valarray>

struct x : public std::ostream
{
  virtual void flush() = 0;
};
void foo(x& os)
{
  os << std::endl;
}

Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.8.4-2ubuntu1~14.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap
--enable-plugin --with-system-zlib --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-std=c++11' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -E -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE va.cxx -mtune=generic -march=x86-64 -std=c++11
-fpch-preprocess -fstack-protector -Wformat -Wformat-security -o va.ii
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.8"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.8
 /usr/include/x86_64-linux-gnu/c++/4.8
 /usr/include/c++/4.8/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-std=c++11' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -fpreprocessed va.ii -quiet
-dumpbase va.cxx -mtune=generic -march=x86-64 -auxbase va -std=c++11 -version
-fstack-protector -Wformat -Wformat-security -o va.s
GNU C++ (Ubuntu 4.8.4-2ubuntu1~14.04) version 4.8.4 (x86_64-linux-gnu)
        compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version
3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (Ubuntu 4.8.4-2ubuntu1~14.04) version 4.8.4 (x86_64-linux-gnu)
        compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version
3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9cb21c615435621dce26fe5e793192fd
In file included from va.cxx:2:0:
/usr/include/c++/4.8/valarray: In instantiation of ‘class std::valarray<x>’:
va.cxx:10:14:   required from here
/usr/include/c++/4.8/valarray:926:5: error: cannot allocate an object of
abstract type ‘x’
     valarray<_Tp>::sum() const
     ^
va.cxx:4:8: note:   because the following virtual functions are pure within
‘x’:
 struct x : public std::ostream
        ^
va.cxx:6:16: note:      virtual void x::flush()
   virtual void flush() = 0;
                ^
In file included from va.cxx:2:0:
/usr/include/c++/4.8/valarray:1033:5: error: cannot allocate an object of
abstract type ‘x’
     valarray<_Tp>::min() const
     ^
va.cxx:4:8: note:   since type ‘x’ has pure virtual functions
 struct x : public std::ostream
        ^
In file included from va.cxx:2:0:
/usr/include/c++/4.8/valarray:1041:5: error: cannot allocate an object of
abstract type ‘x’
     valarray<_Tp>::max() const
     ^
va.cxx:4:8: note:   since type ‘x’ has pure virtual functions
 struct x : public std::ostream
        ^
In file included from va.cxx:2:0:
/usr/include/c++/4.8/valarray:1049:5: error: cannot allocate an object of
abstract type ‘x’
     valarray<_Tp>::apply(_Tp func(_Tp)) const
     ^
va.cxx:4:8: note:   since type ‘x’ has pure virtual functions
 struct x : public std::ostream
        ^
In file included from va.cxx:2:0:
/usr/include/c++/4.8/valarray:1057:5: error: cannot allocate an object of
abstract type ‘x’
     valarray<_Tp>::apply(_Tp func(const _Tp &)) const
     ^
va.cxx:4:8: note:   since type ‘x’ has pure virtual functions
 struct x : public std::ostream
        ^
In file included from va.cxx:2:0:
/usr/include/c++/4.8/valarray:1016:5: error: cannot allocate an object of
abstract type ‘x’
     valarray<_Tp>::resize(size_t __n, _Tp __c)
     ^
va.cxx:4:8: note:   since type ‘x’ has pure virtual functions
 struct x : public std::ostream
        ^

Reply via email to