Bug 33530 - void * arithmetic in bits/string2.h
Summary: void * arithmetic in bits/string2.h
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc   
(Show other bugs)
Version: 7.0
Hardware: i586
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Aaron Brown
Depends On:
TreeView+ depends on / blocked
Reported: 2001-03-28 01:03 UTC by Peter Ajamian
Modified: 2016-11-24 15:04 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-03-28 06:41:27 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Peter Ajamian 2001-03-28 01:03:53 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.73 [en] (Win95; U)

I noticed this when building rpm with a patch that I added in (the one to fix the recursive %if problem in case it matters).
I got a bunch of warnings like this...
/usr/include/bits/string2.h:237: warning: pointer of type `void *' used in arithmetic

Checking the actual line in string2.h...
      __u = __extension__ ((void *) __u + 1);

There's a bunch of those in string2.h

It's explicitly cast to a void * then has pointer arithmetic done on it that way?  Can someone explain why this is?  I'm not the most advanced C 
programmer, but I'm pretty sure that you're _not_ supposed to do pointer arithmetic on a void *.

Reproducible: Always
Steps to Reproduce:
Compile something with -Wall and #include <string.h>.
I specifically saw the problem trying to compile the rpm package and have not tried anything else.	

Actual Results:  Got the warnings mentioned above.

Expected Results:  No warnings.

see above.

Comment 1 Peter Ajamian 2001-03-28 03:04:13 UTC
I just noticed that rpm is compiling with the -Wpointer-arith flag, I suspect that that is also needed to generate the warning.

Additional info:  $rpm -q glibc

The version of rpm I am attempting to compile is rpm-4.0.2-7x which has been tweaked to add in the above mentioned patch.

When I get time later on I'll try to come up with a simple test case that will reproduce the problem.

Comment 2 Peter Ajamian 2001-03-28 06:03:55 UTC
Okay, I managed to reproduce this in very simple means (note it also requires optimization to be turned on)...

cat << EOF > test.c
#include <string.h>
int main(void) {return 0;}
gcc -O -Wpointer-arith -o /dev/null test.c

Output of this is as follows...

/usr/include/bits/string2.h: In function `__strcpy_small':
In file included from /usr/include/string.h:361,
                 from test.c:1:
/usr/include/bits/string2.h:418: warning: pointer of type `void *' used in arithmetic
/usr/include/bits/string2.h:426: warning: pointer of type `void *' used in arithmetic
/usr/include/bits/string2.h:431: warning: pointer of type `void *' used in arithmetic
/usr/include/bits/string2.h:436: warning: pointer of type `void *' used in arithmetic
/usr/include/bits/string2.h:438: warning: pointer of type `void *' used in arithmetic
/usr/include/bits/string2.h:443: warning: pointer of type `void *' used in arithmetic

Just to verify that the file string2.h _really_ came from where I think it does...

$rpm -qf /usr/include/bits/string2.h
$rpm -V glibc-devel-2.2-12

Comment 3 Peter Ajamian 2001-03-28 06:41:23 UTC
Sorry to keep tacking more onto this, anyways...

I found this GNU bug report for libc which describes the problem:

I reported this one as ver 7.0 because I had updated glibc to version 2.2, but I'm still running gcc from RedHat 6.0 (which is actually
egcs).  Apparently updating to a version of gcc >= 2.96 _should_ fix the problem (though I'm not gonna bother testing it since I now
know that it's not a warning which need be taken seriously).  I'll leave this for someone else to close out because it may warrant an
errata for 6.x.

Comment 4 Jakub Jelinek 2001-03-28 08:25:41 UTC
The question is which compiler do you use.
This is a compiler bug and it is for sure fixed in both gcc-2.96-RH and
compat-egcs we shipped in 7.0. 2.95.2 does not have this fixed and from quick
look at the 2.95.2 -> 2.95.3 diff 2.95.3 probably does not have it fixed either.
gcc supports void * arithmetics as an extension, and this is clearly
marked with __extension__.

Note You need to log in before you can comment on or make changes to this bug.