http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58717
Bug ID: 58717 Summary: Pre-calculation optimization is omitted Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: masoud_mxm at yahoo dot com Created attachment 30997 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30997&action=edit Two .cpp source code It seems newer versions of gcc (4.8+) don't pre-calculate functions for constant inputs (Asked the issue here: http://stackoverflow.com/q/19350097/952747). Two source codes attached. unsigned long long s(unsigned long long n) { auto s = 0ULL; for (auto i = 0ULL; i < n; i++) s += i; return s; } const auto N = 1000000000ULL; auto x = s(N); // It computes in run-time and dose NOT compute in compile-time!