www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21304] New: dtoh silently ignore default parameters, leading

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

          Issue ID: 21304
           Summary: dtoh silently ignore default parameters, leading to
                    invalid headers
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: C++
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

The following code:
```
extern(C++):
struct Bar { int a; }
void fooBar (int a = 42, Bar b = Bar.init) {}
```

Will lead to the following header:
```
// Automatically generated by Digital Mars D Compiler v2093

#pragma once

#include <stddef.h>
#include <stdint.h>


struct Bar;

struct Bar
{
    int32_t a;
    Bar() : a() {}
};

extern void fooBar(int32_t a = 42, Bar b);
```

Which won't compile because:
```
ffff.h:17:40: error: missing default argument on parameter 'b'
extern void fooBar(int32_t a = 42, Bar b);
                                       ^
1 error generated.
```

Marking as blocker as dtoh is required by the DMD CI.

--
Oct 11 2020