gcc 3.4.2 vs &address == NULL

Aaron J. Grier aaron at frye.com
Sat Nov 13 00:11:32 UTC 2004


I've been encouraged to bring up another toolchain, and I figured I'd
try and use peter barada's coldfire-hacked gcc 3.4.2.  I've got it
compiled up, but ran across an old issue which apparently was never
resolved:

http://sources.redhat.com/ml/crossgcc/2004-08/msg00013.html

in a nutshell, the optimizer on gcc 3.4.2 assumes that the address of a
variable can't be 0, so it optimizes out any checks.  as pointed out in
the referenced discussion, this is specifically an issue for
bsp_pretasking_hook in m68kpretaskinghook.c.

here's the fix.  (the volatile extern declaration might be overkill.)

-- 
  Aaron J. Grier  |   Frye Electronics, Tigard, OR   |  aaron at frye.com
  "Note that many bands' backline amps produce levels exceeding OSHA
   standards for industrial facilities.  Yet this is considered normal
   working conditions for musicians.  That's showbiz." -- Scott Dorsey
-------------- next part --------------
Index: 0.61/c/src/lib/libbsp/m68k/shared/m68kpretaskinghook.c
--- 0.61/c/src/lib/libbsp/m68k/shared/m68kpretaskinghook.c Fri, 29 Sep 2000 20:11:24 -0700 kaben (rtems/s/b/25_m68kpretas 1.1 644)
+++ 0.61(w)/c/src/lib/libbsp/m68k/shared/m68kpretaskinghook.c Fri, 12 Nov 2004 13:56:27 -0800 aaron (rtems/s/b/25_m68kpretas 1.1 644)
@@ -36,7 +36,7 @@
 
 extern void          *_RamBase;
 extern void          *_WorkspaceBase;
-extern void          *_HeapSize;
+extern volatile void          *_HeapSize;
 
 
 unsigned long  _M68k_Ramsize;
@@ -44,7 +44,7 @@
 void bsp_pretasking_hook(void)
 {
     void         *heapStart;
-    unsigned long heapSize = (unsigned long)&_HeapSize;
+    volatile unsigned long heapSize = (unsigned long)&_HeapSize;
     unsigned long ramSpace;
 
     heapStart =  (void *)


More information about the users mailing list