www.digitalmars.com         C & C++   DMDScript  

D - Bug, or daft developer?

reply "Matthew Wilson" <matthew stlsoft.org> writes:
    synsoft\win32\reg.d(431): function get_Value_EXPAND_SZ cannot access
frame of function expand_environment_strings

What does that mean?
Sep 13 2003
parent reply "Matthew Wilson" <matthew stlsoft.org> writes:
FYI the code looks like

extern (Windows)
{
 DWORD ExpandEnvironmentStringsA(in LPCSTR src, in LPSTR dest, in DWORD
cchDest);
}

private char[] expand_environment_strings(in char[] value)
{
 value ~= 0; // Ensures it's zero-terminated

 DWORD cchRequired = ExpandEnvironmentStringsA(value, null, 0);
 char[] newValue = new char[cchRequired];

 ExpandEnvironmentStringsA(value, newValue, newValue.length);

 return newValue;
}


public class Value
{
    . . .

    char[] get_Value_SZ()

    . . .

    char[] get_Value_EXPAND_SZ()
     {
      char[] value = get_Value_SZ();

      value = expand_environment_strings(value);

      return value;
     }



"Matthew Wilson" <matthew stlsoft.org> wrote in message
news:bk11u3$fha$1 digitaldaemon.com...
     synsoft\win32\reg.d(431): function get_Value_EXPAND_SZ cannot access
 frame of function expand_environment_strings

 What does that mean?
Sep 14 2003
next sibling parent "Matthew Wilson" <matthew stlsoft.org> writes:
btw, if I just put the five lines directly in get_Value_EXPAND_SZ() it all
works fine

"Matthew Wilson" <matthew stlsoft.org> wrote in message
news:bk15p8$lvm$1 digitaldaemon.com...
 FYI the code looks like

 extern (Windows)
 {
  DWORD ExpandEnvironmentStringsA(in LPCSTR src, in LPSTR dest, in DWORD
 cchDest);
 }

 private char[] expand_environment_strings(in char[] value)
 {
  value ~= 0; // Ensures it's zero-terminated

  DWORD cchRequired = ExpandEnvironmentStringsA(value, null, 0);
  char[] newValue = new char[cchRequired];

  ExpandEnvironmentStringsA(value, newValue, newValue.length);

  return newValue;
 }


 public class Value
 {
     . . .

     char[] get_Value_SZ()

     . . .

     char[] get_Value_EXPAND_SZ()
      {
       char[] value = get_Value_SZ();

       value = expand_environment_strings(value);

       return value;
      }



 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bk11u3$fha$1 digitaldaemon.com...
     synsoft\win32\reg.d(431): function get_Value_EXPAND_SZ cannot access
 frame of function expand_environment_strings

 What does that mean?
Sep 14 2003
prev sibling parent reply "Walter" <walter digitalmars.com> writes:
I rewrote the snipped so it is self-contained:
------------------------------------

extern (Windows)
{
    uint ExpandEnvironmentStringsA(in char* src, in char* dest, in uint
cchDest);
}

private char[] expand_environment_strings(in char[] value)
{
    value ~= 0; // Ensures it's zero-terminated

    uint cchRequired = ExpandEnvironmentStringsA(value, null, 0);
    char[] newValue = new char[cchRequired];

    ExpandEnvironmentStringsA(value, newValue, newValue.length);

    return newValue;
}

public class Value
{
    char[] get_Value_SZ();

    char[] get_Value_EXPAND_SZ()
    {
      char[] value = get_Value_SZ();

      value = expand_environment_strings(value);
      return value;
    }
}
-------------------------------------------------
and it compiles without error. The access frame message happens when nested
functions try to access a local in a stack frame not accessible to it.
Sep 14 2003
parent reply "Matthew Wilson" <matthew stlsoft.org> writes:
Well, then it's still a compiler bug, because none of the fns involved are
nested.

"Walter" <walter digitalmars.com> wrote in message
news:bk171v$nev$1 digitaldaemon.com...
 I rewrote the snipped so it is self-contained:
 ------------------------------------

 extern (Windows)
 {
     uint ExpandEnvironmentStringsA(in char* src, in char* dest, in uint
 cchDest);
 }

 private char[] expand_environment_strings(in char[] value)
 {
     value ~= 0; // Ensures it's zero-terminated

     uint cchRequired = ExpandEnvironmentStringsA(value, null, 0);
     char[] newValue = new char[cchRequired];

     ExpandEnvironmentStringsA(value, newValue, newValue.length);

     return newValue;
 }

 public class Value
 {
     char[] get_Value_SZ();

     char[] get_Value_EXPAND_SZ()
     {
       char[] value = get_Value_SZ();

       value = expand_environment_strings(value);
       return value;
     }
 }
 -------------------------------------------------
 and it compiles without error. The access frame message happens when
nested
 functions try to access a local in a stack frame not accessible to it.
Sep 14 2003
parent reply "Walter" <walter digitalmars.com> writes:
I can't fix it because I can't duplicate it.

"Matthew Wilson" <matthew stlsoft.org> wrote in message
news:bk1751$nhv$3 digitaldaemon.com...
 Well, then it's still a compiler bug, because none of the fns involved are
 nested.

 "Walter" <walter digitalmars.com> wrote in message
 news:bk171v$nev$1 digitaldaemon.com...
 I rewrote the snipped so it is self-contained:
 ------------------------------------

 extern (Windows)
 {
     uint ExpandEnvironmentStringsA(in char* src, in char* dest, in uint
 cchDest);
 }

 private char[] expand_environment_strings(in char[] value)
 {
     value ~= 0; // Ensures it's zero-terminated

     uint cchRequired = ExpandEnvironmentStringsA(value, null, 0);
     char[] newValue = new char[cchRequired];

     ExpandEnvironmentStringsA(value, newValue, newValue.length);

     return newValue;
 }

 public class Value
 {
     char[] get_Value_SZ();

     char[] get_Value_EXPAND_SZ()
     {
       char[] value = get_Value_SZ();

       value = expand_environment_strings(value);
       return value;
     }
 }
 -------------------------------------------------
 and it compiles without error. The access frame message happens when
nested
 functions try to access a local in a stack frame not accessible to it.
Sep 14 2003
parent "Matthew Wilson" <matthew stlsoft.org> writes:
I am content to live with the workaround for the moment. I doubt that
ExpandEnvironmentStrings will remain in my Reg module for long, so I'm not
going to worry about it. :)

"Walter" <walter digitalmars.com> wrote in message
news:bk1ae5$rlg$1 digitaldaemon.com...
 I can't fix it because I can't duplicate it.

 "Matthew Wilson" <matthew stlsoft.org> wrote in message
 news:bk1751$nhv$3 digitaldaemon.com...
 Well, then it's still a compiler bug, because none of the fns involved
are
 nested.

 "Walter" <walter digitalmars.com> wrote in message
 news:bk171v$nev$1 digitaldaemon.com...
 I rewrote the snipped so it is self-contained:
 ------------------------------------

 extern (Windows)
 {
     uint ExpandEnvironmentStringsA(in char* src, in char* dest, in
uint
 cchDest);
 }

 private char[] expand_environment_strings(in char[] value)
 {
     value ~= 0; // Ensures it's zero-terminated

     uint cchRequired = ExpandEnvironmentStringsA(value, null, 0);
     char[] newValue = new char[cchRequired];

     ExpandEnvironmentStringsA(value, newValue, newValue.length);

     return newValue;
 }

 public class Value
 {
     char[] get_Value_SZ();

     char[] get_Value_EXPAND_SZ()
     {
       char[] value = get_Value_SZ();

       value = expand_environment_strings(value);
       return value;
     }
 }
 -------------------------------------------------
 and it compiles without error. The access frame message happens when
nested
 functions try to access a local in a stack frame not accessible to it.
Sep 14 2003