🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by James Clark Mon, 29 May 1989 10:47
static members with constructors
#2050
Author: James Clark
Date: Mon, 29 May 1989 10:47
45 lines
1553 bytes
I am not clear about whether g++ is supposed to support static members
with constructors.

Script started on Mon May 29 11:41:42 1989
jclark% cat static.cc
#include <stdio.h>

struct C {
  C() { fputs("C\n", stderr); }
  ~C() { fputs("~C\n", stderr); }
};

struct B {
  static C c;
  B() { fputs("B\n", stderr); }
  ~B() { fputs("~B\n", stderr); }
};

static B b;

main()
{
}
jclark% g++ -g -v static.cc
g++ version 1.35.1-
 /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ static.cc /tmp/cca26825.cpp
GNU CPP version 1.35
 /usr/local/lib/gcc-cc1plus /tmp/cca26825.cpp -quiet -dumpbase static.cc -noreg -version -G -o /tmp/cca26825.s
GNU C++ version 1.35.1- (sparc) compiled by GNU C version 1.35.
static.cc:9: warning: member `c' cannot be static (type `C' needs constructing)
 as /tmp/cca26825.s -o static.o
 /usr/local/lib/gcc-ld++ -C /usr/local/lib/crt0+.o static.o -lg++ /usr/local/lib/gcc-gnulib -lg -lc
jclark% a.out
C
C
B
~B
~C
~C
jclark% exit
jclark% 
script done on Mon May 29 11:42:38 1989

James Clark
jjc@jclark.uucp
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