Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7942 Discussions

bug in C++ compiler 14.0.0: no instance of constructor matches the argument list

Bocci__Andrea
Beginner
5,045 Views

When
 - a constructor is called with an initializer list, made up of {}-initializers for a user-defined type
icpc complains with

error: no instance of constructor matches the argument list

while gcc (4.8.1) happily compiles the code.

How to reproduce:

#include <string>
#include <vector>
 

class Element {
public:
  Element(std::string const & s) :
    data(s)
  { }


  Element(std::string && s) :
    data(s)
  { }


  std::string const & read() const {
    return data;
  }


private:
  std::string data;
};


int main(void) {
  std::vector<Element> elements { { "hello" }, { "world" } };
}

Here is the actual error:

$ icpc -std=c++11 test.cpp -o test
test.cc(24): error: no instance of constructor "std::vector<_Tp, _Alloc>::vector [with _Tp=Element, _Alloc=std::allocator<Element>]" matches the argument list
argument types are: ({...}, {...})
std::vector<Element> elements { { "hello" }, { "world" } };
^

compilation aborted for test.cc (code 2)

0 Kudos
4 Replies
JenniferJ
Moderator
5,045 Views

Thanks for the testcase.

I can see the same error and have filed a bug report (DPD200248554) for it.

Jennifer

0 Kudos
Bocci__Andrea
Beginner
5,045 Views

Hi,
for the record, this is still open with Composer XW 2013 sp1:

$ icpc -v
icpc version 14.0.1 (gcc version 4.8.0 compatibility)

0 Kudos
JenniferJ
Moderator
5,045 Views

btw, this issue has been fixed. it should be in the next 14.0 update - update 2.

Jennifer

0 Kudos
QIAOMIN_Q_
New Contributor I
5,045 Views

Hello Andrea,

This issue has been fixed in the latest compiler sp1 update2. I'm closing this issue now ,since the problem has been fixed. Please feel free to reopen it if this is still an issue for you. Thank you for your issue submission.


Thank you.
--
QIAOMINQ.
Intel Developer Support

0 Kudos
Reply