uniform initialization of temporary reference

Skip to first unread message


May 17, 2016, 7:30:10 AM5/17/16
{ edited by mod to shorten lines to ~70 characters. -mod }

consider the following code

int x;
using intref = int&;
intref w{x}; // A
intref{x}; // B

now, line A compiles correctly both in clang and gcc ( it didn't as of
c++11, defect fixed in c++14 AFAIK )

the problem is line B: clang treats it the way one would expect
( a temporary reference is bound to x ) whereas gcc 4.9 treat it in
the old defected way ( a temporary of type int is created and bound to
the reference, resulting in a compiler error ).

Who's right here ? thank you

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Reply all
Reply to author
0 new messages