lkml.org 
[lkml]   [2000]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] removal of "static foo = 0"
Date
Albert D. Cahalan writes:
> It is too late to fix things now. It would have been good to
> have the compiler put explicitly zeroed data in a segment that
> isn't shared with non-zero or uninitialized data, so that the
> uninitialized data could be set to 0xfff00fff to catch bugs.
> It would take much effort over many years to make that work.

Oh dear, here's that misconception again.

static int a;

isn't a bug. It is not "uninitialised data". It is defined to be
zero. Setting the BSS of any C program to contain non-zero data will
break it. Fact. The only bug you'll find is the fact that you're
breaking the C standard.

There is only two places where you come across uninitialised data:

1. memory obtained from outside text, data, bss limit of the program
(ie, malloced memory)
2. if you use auto variables which may be allocated on the stack

All variables declared at top-level are initialised. No questions
asked. And its not a bug to rely on such a fact.
_____
|_____| ------------------------------------------------- ---+---+-
| | Russell King rmk@arm.linux.org.uk --- ---
| | | | http://www.arm.linux.org.uk/personal/aboutme.html / / |
| +-+-+ --- -+-
/ | THE developer of ARM Linux |+| /|\
/ | | | --- |
+-+-+ ------------------------------------------------- /\\\ |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:47    [W:0.086 / U:10.880 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site