www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - bug in 102 with structs

reply Ben Hinkle <bhinkle4 juno.com> writes:
module bug;

import std.stdarg;

struct Test {

  void add(...) {
    Test other = va_arg!(Test)(_argptr);
    foreach( int value; other ) {

  void foo() {
    printf("left is %p\n",left);

  void bar() {
    printf("left is %p\n",left);

  int opApply(int delegate(inout int val) dg){
    return 0;

  void* left;
int main() {
  Test m;
  return 0;

dmd bug.d on linux (I haven't tried Windows) and running gives
left is (nil)
left is 0xbfffe94c

It should be (nil) both times. In other words when foo calls bar the *this
pointer is probably wrong. Everything works fine if I comment out any part
of the add() function or even just move add() to be defined after foo and
bar - even when it never gets called. The problem wasn't in 101. This bug
impacts MinTL but since moving functions around might be a work-around I'll
try that.

Sep 26 2004
parent "Thomas Kuehne" <eisvogel users.sourceforge.net> writes:
added as odd_bug_02 to dstress

Sep 26 2004