In C++0x, constant initializer_lists do not seem visible to the optimiser, leading to sub-optimal code. Consider as a simple example:
#include <initializer_list> int max_val(std::initializer_list<int> il) { int i = *(il.begin()); int j = *(il.begin() + 1); return (i > j ? i : j); } int main(void) { return max_val({1,2}); } I would expect 'main' to be reduced to just '2' at a suitable optimisation level. At -O3 the body max_val is inlined the values {1,2} are not. Is there some reason constant initalizer_lists cannot be made visible to optimisation? -- Summary: constant initializer_list not optimised Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: chris at bubblescope dot net GCC host triplet: i686-apple-darwin10 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41997