Nim Nuggets: Nim talk at Strange Loop 2021

Walter Bright newshound2 at digitalmars.com
Sun Oct 17 22:53:29 UTC 2021


On 10/17/2021 2:11 PM, max haughton wrote:
> On Sunday, 17 October 2021 at 19:18:25 UTC, Walter Bright wrote:
>> On 10/17/2021 3:03 AM, Ola Fosheim Grøstad wrote:
>>> [...]
>>
>> You're confusing data flow analysis and function inlining with ctfe. I know 
>> how data flow optimizers work, I was the first to implement one for DOS 
>> compilers in the 80s.
>>
>> [...]
> 
> https://gcc.godbolt.org/z/jr5W6rY1W
> 
> If I read you correctly, gcc circa '06 could do what you describe. Or do you 
> mean in windows land?

------------------------
mercury> cat test.c
int square(int x) { return x * x; }

const int c = square(2);

mercury> cc test.c -O3
test.c:3:1: error: initializer element is not constant
  const int c = square(2);
  ^
mercury> cc test.c --version
cc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-------------------------

Your example is fundamentally different:

-------------------------
int square(int x) { return x * x; }

int main()
{
     const int s = square(2);  <== not a constant-expression
     return s;


}
----------------


More information about the Digitalmars-d mailing list