Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 48797
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: GCC Porting Team <gcc-porting@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Ed Catmur <ed@catmur.co.uk>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 48797 depends on: Show dependency tree
Bug 48797 blocks: 48798
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2004-04-23 10:22 0000
Reported upstream, including test case and patch. 

Patch is suitable for adding to gentoo.org glibc ebuild.

------- Comment #1 From Travis Tilley (RETIRED) 2004-04-23 11:07:13 0000 -------
would you mind providing a little more information here? this is a pretty
sparse bug report.

of course, we should really roll out a new snapshot anyways.

------- Comment #2 From Ed Catmur 2004-04-23 11:41:13 0000 -------
Sorry. Upstream URL is http://sources.redhat.com/bugzilla/show_bug.cgi?id=130

Copy of bug:

=============================================

>  $ cat foo.c
>  #include <string.h>
>  int main(int argc, char *argv[]) {
>          return (int) ((strpbrk("string", "n")) - "string");
>  }
>  $ /usr/i686-pc-linux-gnu/gcc-bin/3.4/gcc -O foo.c
>  foo.c: In function `main':
>  foo.c:3: error: invalid operands to binary -

-O is necessary to make gcc include the optimising macro definition of strpbrk()
in bits/string2.h:

#  define strpbrk(s, accept) \
  __extension__								      \
  ({ char __a0, __a1, __a2;						      \
     (__builtin_constant_p (accept) && __string2_1bptr_p (accept)	      \
      ? ((__a0 = ((__const char  *) (accept))[0], __a0 == '\0')		      \
	 ? ((void) (s), NULL)						      \
	 : ((__a1 = ((__const char *) (accept))[1], __a1 == '\0')	      \
	    ? strchr (s, __a0)						      \
	    : ((__a2 = ((__const char *) (accept))[2], __a2 == '\0')	      \
	       ? __strpbrk_c2 (s, __a0, __a1)				      \
	       : (((__const char *) (accept))[3] == '\0'		      \
		  ? __strpbrk_c3 (s, __a0, __a1, __a2)			      \
		  : strpbrk (s, accept)))))				      \
      : strpbrk (s, accept)); })
# endif

Offending line is:
	 ? ((void) (s), NULL)						      \

This is not detected as a bug when compiling with gcc 3.3.

Test case and patch attached.

==========================================

I have checked the glibc ViewCVS and the bug is in the current CVS head, so a new snapshot will not help with this bug (not yet, anyway).

------- Comment #3 From Ed Catmur 2004-04-23 11:58:51 0000 -------
To be perfectly clear:

This is a bug in bits/string2.h in glibc: the macro definition of strpbrk() expands to a ?: expression which can have a type of (char *) or NULL, which in Linux is of type (void *). This is a bug as one cannot use (void *) everywhere (char *) is allowable, in this instance on the LHS of the - operator.

It manifests itself with gcc 3.4, when compiling with -O{,1,2,3}: gcc 3.4 as gcc 3.3 is lax and does not detect the bug (possibly an implicit cast is performed, but what do I know) and -O{,1,2,3} as -Os and (no -O flag) prevent the macro form of strpbrk() being used.

This needs to be fixed upstream, but in the meantime can be fixed within gentoo.org. 

It will show up as bugs compiling packages with gcc 3.4, e.g. bug 48798.

------- Comment #4 From Ed Catmur 2004-04-30 08:42:09 0000 -------
Upstream:

>  ------- Additional Comment #3 From Jakub Jelinek  2004-04-30 08:52  [reply] -------
> 
> Fix commited to glibc CVS on 2004-04-29.

Will close when new glibc is packaged from cvs.

------- Comment #5 From Ed Catmur 2004-04-30 17:49:34 0000 -------
http://sources.redhat.com/bugzilla/show_bug.cgi?id=130#c3

------- Comment #6 From Joshua Kinard 2004-05-01 17:20:19 0000 -------
I'm testing a glibc compile that includes a patch for this bug and a sparc bug
(taken from their CVS).  If it works out okay, I'll make a -r1 ebuild with
them.

------- Comment #7 From Travis Tilley (RETIRED) 2004-07-11 14:27:59 0000 -------
well, this should work if using a snapshot later than 2004-04-29 like amd64
does... anyone object to adding this patch to 20040420 so that x86 gets the
fix?

i'll poke at morfic too, since he's working on getting gcc 3.4 up to par on
x86.

------- Comment #8 From Travis Tilley (RETIRED) 2004-07-11 15:06:47 0000 -------
<morfic> and when i make x86-gcc-3.4 profile ill make 0605 glibc part of it

------- Comment #9 From Disenchanted (RETIRED) 2004-07-11 15:45:19 0000 -------
i plan on making a x86-gcc3.4 profile based on sys-libs/glibc-2.3.4.20040605

upstream fixes like this show exactly why it makes sense to stick to this version that has worked for me (x86) for the last 36 days w/o a hitch, all i have come across was lousy sources needing fixing, so far nothing relating to glibc

Travis: stop causing mid air collisions!

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug