🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by "Francis Sullivan" Tue, 26 Sep 1989 23:11
g++ 1.34.2 sizeof bug
#441
Author: "Francis Sullivan"
Date: Tue, 26 Sep 1989 23:11
31 lines
1079 bytes
%
% cat size.cc
#include <stream.h>
class Int {
  private:
    int value;
    char str[20];

  public:
    Int(int i) { value = i; };
    operator()() { return value; };
};

main() {
Int a = 1, b = 2, c = 3;
Int& all[/* max_all */] = { a, b , c};
const max_all = (sizeof(all)/sizeof(Int&));

cout << "max_all's value is " << max_all << "\n";
for (int i = 0 ; i < max_all; i++)
   cout << "all[" << i << "] = " << all[i]() << "\n";
}
% g++ -v
g++ version 1.34.2
% cat /etc/motd
SunOS Release 4.0 (SQDL60) #1: Fri Mar 10 18:55:26 MST 1989
% g++ size.cc
% a.out
max_all's value is 0
%
-- should be 3, and it is if you comment out 'char str[20];'
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