Re: [cfe-users] Why does clang not always produce constant value for same static constexpr

2019-09-25 Thread David Blaikie via cfe-users
On Wed, Sep 25, 2019 at 2:03 PM Christopher Williams wrote: > Thank you Dave. I have an understanding of constexpr evaluation, and > realise the compiler is free to do what it likes in all but test4... I > suppose I'd really like to know if there is an actual limit/threshold in > place. If test3

Re: [cfe-users] Why does clang not always produce constant value for same static constexpr

2019-09-25 Thread Christopher Williams via cfe-users
Thank you Dave. I have an understanding of constexpr evaluation, and realise the compiler is free to do what it likes in all but test4... I suppose I'd really like to know if there is an actual limit/threshold in place. If test3 is changed to use 100 characters it does as I expect, any more than th

Re: [cfe-users] Why does clang not always produce constant value for same static constexpr

2019-09-25 Thread David Blaikie via cfe-users
constexpr is a red herring here - except in 4, where you've used the constexpr keyword to create a constexpr context, in 1-3 these are just normal function calls the compiler optimizes as it sees fit - and it seems it saw fit to unroll and optimize to a constant cases 1 and 2, but not case 3 (perha

[cfe-users] Why does clang not always produce constant value for same static constexpr

2019-09-25 Thread Christopher Williams via cfe-users
Given the code below, clang produces a constant value for test1, test2 and test4. Why doesn't it for test3? This is more of a curious query, than a request for help, but if someone does have the answer, I'd appreciate as much detail as possible. || |staticconstexprintcount_x(constchar*str){int