public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem with braced-init-lists and explicit ctors
@ 2014-02-02  9:10 Joaquin M Lopez Munoz
  2014-02-02  9:26 ` Marc Glisse
  0 siblings, 1 reply; 5+ messages in thread
From: Joaquin M Lopez Munoz @ 2014-02-02  9:10 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-02-03  7:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-02  9:10 Problem with braced-init-lists and explicit ctors Joaquin M Lopez Munoz
2014-02-02  9:26 ` Marc Glisse
2014-02-02  9:38   ` Joaquin M Lopez Munoz
2014-02-02 21:07   ` Michael Powell
2014-02-03  7:12     ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).