🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Per Mildner Mon, 29 May 1989 03:40
sizeof and uninitialized args
#2049
Author: Per Mildner
Date: Mon, 29 May 1989 03:40
36 lines
985 bytes
I'm Per-Mildner@AIDA.CSD.UU.SE

 Configuration:
SUN 4 with OS 4
tm.h -> config/tm-sparc+.h
md -> config/sparc.md
g++ version 1.35.0
g++ -Wall -O program.cc

In method struct C *C::C ():
sizeof-bug.cc:17: field `r' used before initialized (after assignment to `this')

// -*- Mode:C++ -*-
// This file: sizeof-bug.cc

class B {
public:
  int x;
  B() {}
  B(B& init) {
    x = init.x;
  }
};

class C {
public:
  B r[1];
  C() {
    this = (C*) new char[sizeof r]; // *** Shouldn't care if initialized?
  }
};

int main (int argc, char* argv[]) {
  return 0;
};
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads