www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13427] New: [REG2.066] cannot inline default argument


          Issue ID: 13427
           Summary: [REG2.066] cannot inline default argument alloca(...)
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: Marco.Leise gmx.de

A trick that Andrei and I came up with not long ago, to use alloca as part of a
default argument does not work any more. I developed this with someone on #D
one night and use it everywhere I need to pass a D string to a C API.

Use cases:
http://forum.dlang.org/thread/i1gnlo$18g0$1 digitalmars.com#post-i1gql2:241k6o:241:40digitalmars.com


import core.stdc.stdlib;

enum allocaLimit = 1024;

auto wcharPtr(alias str)(void* buffer = 2*(str.length+1) <= allocaLimit ?
alloca(2*(str.length+1)) : null)
    // ...

void main()


Sep 05 2014