www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23913] New: __traits(getMember) fails for some C symbols

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

          Issue ID: 23913
           Summary: __traits(getMember) fails for some C symbols
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: betterC
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

This works in v2.102.0 but fails in v2.013.x:

library.c:

```
typedef enum SomeEnum
{
    foo = 0,
    bar = -10000,
} SomeEnum;
```

mod.d:

```
module mod;

import library;

alias x = __traits(getMember, library, "SomeEnum");
```

```
$ dmd -c library.c mod.d
[1]    28653 illegal hardware instruction (core dumped)  dmd -c library.c mod.d
core.exception.AssertError src/dmd/expressionsem.d(13055): Assertion failure
```

Specifically:
https://github.com/dlang/dmd/blob/a45f4e9f43e9fdbf0b666175e5e66b1ce4f561f6/compiler/src/dmd/expressionsem.d#L13054

It seems to only fail for typedef'ed enums like this.

--
May 12 2023