This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem with braced-init-lists and explicit ctors


Using GCC 4.8 -std=c++11. The following overload resolution is not
ambiguous as bar::bar is explicit, which is fine: 

struct foo 
{ 
  foo(int){} 
}; 

struct bar 
{ 
  explicit bar(int){} 
}; 

void f(foo){} 
void f(bar){} 

int main() 
{ 
  f(0); 
} 

But if I change the call statement to 

int main() 
{ 
  f({0}); 
} 

then I get 

main.cpp:16:8: error: call of overloaded 'f(<brace-enclosed initializer
list>)' is ambiguous 
   f({0}); 
        ^ 
main.cpp:16:8: note: candidates are: 
main.cpp:11:6: note: void f(foo) 
 void f(foo){} 
      ^ 
main.cpp:12:6: note: void f(bar) 
 void f(bar){} 
      ^ 

Is this a bug or am I missing some subtlety in the standard? Thank you, 

JoaquÃn M LÃpez MuÃoz 
TelefÃnica Digital


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]