lkml.org 
[lkml]   [2002]   [Jan]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] C undefined behavior fix
On Wed, Jan 02, 2002 at 08:39:20AM -0700, Tom Rini wrote:
> Well, Paulus wrote 'strcpy' not 'memcpy', so why does gcc get to assume
> it's safe to change it? In this case it's certainly not.

But unless you trigger undefined behaviour, strcpy(x, "foobar" + n) is
equal to memcpy(x, "foobar" + n, sizeof("foobar") - n); and the latter is
more efficient (you don't have to check for end-of-string during copying).

> > It is not a workaround, it is a fix to an invalid code, which gets
> > triggered by particular optimization.
>
> By a particular optimization that's not present before gcc-3.0, and
> happens to break things under some conditions, as you've seen.

It just happens to do a different thing than it used to when seeing code
with particular case of undefined behaviour.

Jakub
-
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.204 / U:0.568 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site