[Issue 20479] octal integer literals don't work with BetterC mode

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 18 09:53:01 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=20479

Mathias LANG <pro.mathias.lang at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |betterC
                 CC|                            |pro.mathias.lang at gmail.com
           Hardware|x86                         |All
                 OS|Mac OS X                    |All
           Severity|enhancement                 |normal

--- Comment #2 from Mathias LANG <pro.mathias.lang at gmail.com> ---
Actually the issue is valid, but it would have been nice to post the error
messages you're getting.

First, using the op's code, we get the following error with the latest DMD
(2.090.0):
```
dmd -betterC foo.d
/usr/local/opt/dmd/include/dlang/dmd/std/array.d(965): Error: TypeInfo cannot
be used with -betterC
```

Which is obviously wrong, as `octal` should not lead to code being emitted in
the binary.
Then, if we tweak the code a bit:
```
import core.stdc.stdio;
import std.conv : octal;

extern(C) void main()
{
    enum b = octal!"167";
    printf("Octal literal: %d\n", b);
}
```

We get the following link error:
```
dmd -betterC -run foo.d
Undefined symbols for architecture x86_64:
  "__D3std4conv14isOctalLiteralFNaNbNiNfxAyaZb", referenced from:
      __D3std4conv__T5octalTiZQjFNaNbNiNfxAyaZi in foo.o
ld: symbol(s) not found for architecture x86_64
```

Turning the symbol into a `static immutable` doesn't help either.

--


More information about the Digitalmars-d-bugs mailing list