Skip to content

ImportC: macro causes assertion failure #21246

@drpriver

Description

@drpriver
#define M(x) _Generic(x, (

Output:

---                                                                                                                                                                                                                                                                      
ERROR: This is a compiler bug.                                                                                                                                                                                                                                           
Please report it via https://github.com/dlang/dmd/issues                                                                                                                                                                                                                 
with, preferably, a reduced, reproducible example and the information below.                                                                                                                                                                                             
DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction.                                                                                                                                                                                     
---                                                                                                                                                                                                                                                                      
DMD v2.111.0-137-g0cc3de3939                                                                                                                                                                                                                                             
predefs   D_ObjectiveC DigitalMars LittleEndian D_Version2 all D_SIMD Posix OSX darwin CppRuntime_LLVM CppRuntime_Clang D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert D_PreConditions D_PostConditions D_Invariants D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat     
binary    generated/osx/release/64/dmd                                                                                                                                                                                                                                   
version   v2.111.0-137-g0cc3de3939                                                                                                                                                                                                                                       
config    generated/osx/release/64/dmd.conf                                                                                                                                                                                                                              
DFLAGS    -Igenerated/osx/release/64/../../../../druntime/import -Igenerated/osx/release/64/../../../../../phobos -L-Lgenerated/osx/release/64/../../../../../phobos/generated/osx/release/64 -fPIC                                                                      
---                                                                                                                                                                                                                                                                      
core.exception.AssertError@src/dmd/cparse.d(6318): Assertion failure                                                                                                                                                                                                     
----------------                                                                                                                                                                                                                                                         
??:? object.Throwable.TraceInfo core.runtime.defaultTraceHandler(void*) [0x100d7f182]

Other examples:

#define M(a,b) _Generic(val, int(int) a
#define X(str,val) _Generic(val, M(F) struct{int foo;}: 0)(__FILE__, __func__, __LINE__, str, val)

I suspect this and #21244 are related as the logic in https://github.com/dlang/dmd/blob/master/compiler/src/dmd/cparse.d#L3024 can leave a null symbols in some cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions