Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Bocci__Andrea
Beginner
1,181 Views

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

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
1,181 Views

Thanks for the testcase.

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

Jennifer

Bocci__Andrea
Beginner
1,181 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)

JenniferJ
Moderator
1,181 Views

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

Jennifer

QIAOMIN_Q_
New Contributor I
1,181 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