D - Bug, or daft developer?
- Matthew Wilson (3/3) Sep 13 2003 synsoft\win32\reg.d(431): function get_Value_EXPAND_SZ cannot access
- Matthew Wilson (27/30) Sep 14 2003 FYI the code looks like
- Matthew Wilson (4/37) Sep 14 2003 btw, if I just put the five lines directly in get_Value_EXPAND_SZ() it a...
- Walter (28/28) Sep 14 2003 I rewrote the snipped so it is self-contained:
- Matthew Wilson (5/33) Sep 14 2003 Well, then it's still a compiler bug, because none of the fns involved a...
- Walter (3/47) Sep 14 2003 I can't fix it because I can't duplicate it.
- Matthew Wilson (7/57) Sep 14 2003 I am content to live with the workaround for the moment. I doubt that
    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
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
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
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
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 whennestedfunctions try to access a local in a stack frame not accessible to it.
 Sep 14 2003
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 whennestedfunctions try to access a local in a stack frame not accessible to it.
 Sep 14 2003
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...areWell, then it's still a compiler bug, because none of the fns involveduintnested. "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, incchDest); } 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 whennestedfunctions try to access a local in a stack frame not accessible to it.
 Sep 14 2003








 
  
  
 
 "Matthew Wilson" <matthew stlsoft.org>
 "Matthew Wilson" <matthew stlsoft.org> 