lkml.org 
[lkml]   [2002]   [Jan]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] C undefined behavior fix
On Mon, Jan 07, 2002 at 04:16:32PM -0800, mike stump wrote:
>
> I assume you meant something like this:
>
> char * volatile cp;
>
> main() {
> return cp - cp;
> }

No. No. In this case you're giving cp external linkage, which means it
can be observed from the outside. Plus, you're reading it multiple times,
which in the case of volatile definitely means it should be read multiple
times because it might be modified by something external between those
reads, and that may be exactly what you want to observe with your code.

What I mean (and what we're seeing in RELOC) is more like this:

char *foo() {
char * volatile cp = NULL;
return cp;
}


Jeroen

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:15    [W:0.044 / U:1.688 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site