Subject: g++ prob
To: RiscBSD <port-arm32@NetBSD.ORG>
From: Patrick Welche <prlw1@cam.ac.uk>
List: port-arm32
Date: 05/08/1997 09:44:36
I know the code is wrong, but I was surprised at the /netbsd errors!

#include <iostream.h>

int main()
{
  void *foo;
  foo=(void *)new int;
  *foo=(void)3;
  cout << (int)*foo;

  return 0;
}

% g++ test.cc -Wall
test.cc: In function `int main()':
test.cc:7: invalid use of void expression
test.cc:7: confused by earlier errors, bailing out
/netbsd: nogo1, Data abort: 'Translation fault (section)'
           status = 005 address = 73696884 PC = 0012d6dc
/netbsd: nogo1, Data abort: 'Translation fault (section)'
           status = 005 address = 73696884 PC = 0012d6dc
/netbsd: 0012d6dc : PPWe : e5971010 :    LDR     r1, [r7, #0x0010]
/netbsd: 0012d6dc : PPWe : e5971010 :    LDR     r1, [r7, #0x0010]
/netbsd: Process = f1595d00 pid = 175 comm = cc1plus
/netbsd: Process = f1595d00 pid = 175 comm = cc1plus
/netbsd: CPSR=60000013 Traceback info (frame=f2d90fb8)
/netbsd: CPSR=60000013 Traceback info (frame=f2d90fb8)
/netbsd: fp->lr=f01000e0 fp->pc=f010f440
/netbsd: fp->lr=f01000e0 fp->pc=f010f440
/netbsd: Trapframe PC = 0012d6dc
/netbsd: Trapframe PC = 0012d6dc
/netbsd: Trapframe SPSR = 20000010
/netbsd: Trapframe SPSR = 20000010

whereas

#include <stdio.h>
#include <stdlib.h>

int main()
{
  void *foo;
  foo=(void *)calloc(1,sizeof(int));
  *foo=(void)3;
  printf("foo: %i\n",(int)*foo);

  return 0;
}

just gives

% gcc -Wall test.c
test.c: In function `main':
test.c:8: warning: dereferencing `void *' pointer
test.c:8: invalid use of void expression
test.c:9: warning: dereferencing `void *' pointer
test.c:9: void value not ignored as it ought to be

For information to anyone who fiddles with the complier!

Patrick