https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65322
--- Comment #6 from Wolfgang Roehrl ---
Thank you and have a nice day!
Vorsitzender des Aufsichtsrats: Dr. Peter-Alexander Wacker
Geschäftsführer: Dr. Walter Schlebusch (Vorsitzender, CEO),
Stefan Auerbach, Hans Wolfgang Kunz, Ralf Wintergerst,
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65322
--- Comment #5 from Jonathan Wakely ---
(In reply to Jonathan Wakely from comment #4)
> Just use m_counter( b ? 1u : 0u ) or m_counter{ short(b ? 1u : 0u) }
Oops, the second one should be m_counter{ (unsigned short)(b ? 1u : 0u) }
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65322
--- Comment #4 from Jonathan Wakely ---
(In reply to Wolfgang Roehrl from comment #3)
> The compiler rejects this program too - is this correct?
Yes. Adding constexpr to the constructor only means that it *can* be used in
constant-expressions, n
l b = true)
: m_counter{ b ? 1u : 0u }
{}
std::atomic m_counter;
};
S x;
The compiler rejects this program too - is this correct?
Wolfgang
Von:"redi at gcc dot gnu.org"
An: wolfgang.roe...@gi-de.com
Datum: 05.03.2015 11:54
Betreff: [Bug c++/65322] Narrowing
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65322
--- Comment #2 from Jonathan Wakely ---
N.B. to make the code compile just don't use braces for the initialization:
: m_counter( b ? 1u : 0u )
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65322
Jonathan Wakely changed:
What|Removed |Added
Status|UNCONFIRMED |RESOLVED
Resolution|---