On Sat, Jan 25, 2025 at 6:52 PM Kok How Teh via Gcc-bugs <gcc-bugs@gcc.gnu.org> wrote: > > vector<long> a = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}; > assert(43589145600 == accumulate(a.begin(), a.end(), 1, multiplies())); > > That assertion fails! What do I miss?
You missed that 1 is in type int and you want to accumulate in long not get an overflow. So you should use 1l or (long)1. Note also this mailing list is for automated messages from GCC's bugzilla and not normally answered to. Plus this is not a help mailing list but rather it is for reporting bugs. There are other mailing lists/forums to get help with C++. Thanks, Andrew