Re:Brilliant Jerks Cost More Than They Are Worth
by sqeaky on Wednesday February 15, 2017 @06:13PM
(#13656396)
It used to, but it doesn't anymore, presuming you use a reasonably recent compiler. If you enable optimizations the assembly for that snippet and the default constructor are identical, I last checked on some GCC 5 flavor, but I think it was like this all the way back in GCC 3 something.
Compilers can do some pretty fancy things with literals because they know they optimize constants known at compile time.
Re:Brilliant Jerks Cost More Than They Are Worth
by hermitdev on Thursday February 16, 2017 @11:20AM
(#13661118)
I just started using GCC 5.4 - I'll have to check again. Last I checked was around 4.8, and it was still generating sub optimal code with the empty literal.
Compilers can do some pretty fancy things with literals because they know they optimize constants known at compile time.