- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#include <vector>
struct A : public std::vector<double>
{ using std::vector<double>::vector; };
compiles fine with g++ and clang, but the Intel compiler [icpc (ICC) 17.0.0 20160720] gives me (with flag -std=c++11
)
error: function template "A::A(_ForwardIterator, _ForwardIterator, const std::__1::allocator &)" already inherited from "std::__1::vector>"
at the using
directive. Any ideas why this is happening and/or how to solve it?
Should I just start suspecting an icpc bug or just blame my poor coding skills?
I'd appreciate any help, thanks!
- Tags:
- CC++
- Development Tools
- Intel® C++ Compiler
- Intel® Parallel Studio XE
- Intel® System Studio
- Optimization
- Parallel Computing
- Vectorization
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Simone,
They're called "inherited" not "imported" constructors.
I can't reproduce the error you are seeing. Can you do the following:
(1) uname -a
(2) gcc -v
(3) icc -v
and cut and paste the results here?
This is what I see - it's possible that there was a bug that has been fixed.
sptel15-162> icc -v
icc version 17.0.2 Beta (gcc version 6.3.0 compatibility)
sptel15-163> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/site/spt/rdrive/ref/gcc/6.3.0/rhel60/efi2/bin/../libexec/gcc/x86_64-linux-gnu/6.3.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../gcc-6.3.0/configure --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --enable-bootstrap --enable-__cxa_atexit --enable-threads=posix --prefix=/home/cmplr/bata/ref/gcc/6.3.0/rhel60/efi2 --with-gmp=/home/cmplr/bata/comp/ia32e/gmp-5.1.3 --with-mpfr=/home/cmplr/bata/comp/ia32e/mpfr-3.1.2 --with-mpc=/home/cmplr/bata/comp/ia32e/mpc-1.0.2 --enable-languages=c,c++,objc,fortran
Thread model: posix
gcc version 6.3.0 (GCC)
sptel15-164> cat t.cpp
#include <vector>
struct A : public std::vector<double>
{ using std::vector<double>::vector; };
sptel15-165> icpc -std=c++11 -c t.cpp
sptel15-166>
thanks
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you all for your replies.
(1) uname -a
Darwin dhcp-192-033-100-233 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan 9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 x86_64
(2) gcc -v
Target: x86_64-apple-darwin15.6.0
Configured with: ../configure --build=x86_64-apple-darwin15.6.0 --prefix=/usr/local/Cellar/gcc/6.3.0_1 --libdir=/usr/local/Cellar/gcc/6.3.0_1/lib/gcc/6 --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-6 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --with-build-config=bootstrap-debug --disable-werror --with-pkgversion='Homebrew GCC 6.3.0_1' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --enable-plugin --disable-nls --enable-multilib
Thread model: posix
gcc version 6.3.0 (Homebrew GCC 6.3.0_1)
(3) icc -v
icc version 17.0.0 (gcc version 4.9.0 compatibility)
(4) clang -v
Apple LLVM version 7.3.0 (clang-703.0.29)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
As you can see, I omitted I'm on OS X - couldn't see why this would be relevant at first, but now I'm starting to suspect it.
Thanks again for looking into this!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just to be complete:
$ g++-6 -std=c++11 -c try.cpp -o try.o
$ clang -std=c++11 -c try.cpp -o try.o
$ icc -std=c++11 -c try.cpp -o try.o
try.cpp(3): error: function template "A::A(_ForwardIterator, _ForwardIterator, const std::__1::allocator<double> &)" already inherited from "std::__1::vector<double, std::__1::allocator<double>>"
{ using std::vector<double>::vector; };
^
compilation aborted for try.cpp (code 2)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Sergey,
I literally copy-pasted the three lines of code above, and that's it.
[I had actually deleted the old minimal working example =)]
If you still insist, I can upload it.
By the way, I also have access to a cluster running Linux (CentOS) with different icc versions:
icc -std=c++11 -c try.cpp
*compiles* with icc 15.0.3 and 16.0.1
while with 14.0.1 or 14.0.5 I get:
try.cpp(3): error #1140: a using-declaration may not name a constructor or destructor
Best,
S.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was able to reproduce the problem on MacOS (their version of the <vector> class is needed to see the error).
Below is a reduced example. The problem seems to be that the compiler doesn't recognize that these two overloads are distinct because they only differ in the value of the default argument (which is used for SFINAE). Clang and Windows accept the code below, but both GNU and Interl give a spurious error. I have entered this defect in our bug tracking database as DPD200417938. Thanks for reporting it.
Judy
// clang and MSVC++ 2015 accept this, icpc and icl do not
template <bool, class _Tp = void>
struct enable_if {
typedef int type;
};
template <class _Tp>
struct enable_if<true, _Tp> {typedef char type;};
struct C
{
template <class T> C(T, typename enable_if<!T::value>::type* = 0);
template <class T> C(T, typename enable_if<T::value>::type* = 0);
};
struct A : public C
{
using C::C;
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your insight Judy.
I appreciate your help.
Can the bug database be seen by users to check progress status?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No sorry this is an internal bugs database. If you would like to enter a ticket via Intel Premier support and tell them about the number then you could monitor the status that way.
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is 2022 and I am getting this error still:
MacOS 11.6.3 Big Sur
$ icpc --version
icpc (ICC) 2021.5.0 20211109
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.
error: function template "vtkFoamPtrList<T>::vtkFoamPtrList(_ForwardIterator, _ForwardIterator, const std::__1::allocator<vtkFoamEntryValue *> &) [with T=vtkFoamEntryValue]" already inherited from "std::__1::vector<vtkFoamEntryValue *, std::__1::allocator<vtkFoamEntryValue *>>"
using std::vector<T*>::vector;
^
As this is the most recent compiler, what is the fix or code change to get past this error? This code builds with the default Clang compiler.
Thanks

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page