gcc-4.6.0-0.11.fc15.x86_64 breaks strcmp?

2011-03-07 Thread Richard W.M. Jones
Compiling libguestfs using gcc-4.6.0-0.11.fc15.x86_64 gives lots of:

error: assuming signed overflow does not occur when changing X +- C1 cmp C2 to 
X cmp C1 +- C2 [-Werror=strict-overflow]

These seem to be associated with code that does 'if (strcmp (s1, s2) == 0)'

For example:

dir.c: In function ‘do_rm_rf’:
dir.c:59:7: error: assuming signed overflow does not occur when changing X +- 
C1 cmp C2 to X cmp C1 +- C2 [-Werror=strict-overflow]

--
int
do_rm_rf (const char *path)
{
  int r;
  char *buf, *err;

  if (STREQ (path, /)) {  -- here
reply_with_error (cannot remove root directory);
return -1;
  }
--

where STREQ is a simple macro:

#define STREQ(a,b) (strcmp((a),(b)) == 0)

AFAIK this code should be correct?  I can't find anything at all about
this specific error from Google.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel

Re: gcc-4.6.0-0.11.fc15.x86_64 breaks strcmp?

2011-03-07 Thread Adam Jackson
On 3/7/11 9:49 AM, Richard W.M. Jones wrote:
 Compiling libguestfs using gcc-4.6.0-0.11.fc15.x86_64 gives lots of:

 error: assuming signed overflow does not occur when changing X +- C1
 cmp C2 to X cmp C1 +- C2 [-Werror=strict-overflow]

 These seem to be associated with code that does 'if (strcmp (s1, s2)
 == 0)'

 For example:

 dir.c: In function ‘do_rm_rf’: dir.c:59:7: error: assuming signed
 overflow does not occur when changing X +- C1 cmp C2 to X cmp C1 +-
 C2 [-Werror=strict-overflow]

I'm not able to repro this with -0.12.fc15.  If I had to guess, you've 
got a macro for strcmp somewhere that's making type assumptions.  What 
does the .i file look like if you compile with -save-temps ?

- ajax
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel

gcc-4.6.0-0.12.fc15.x86_64 breaks strcmp? (was: Re: gcc-4.6.0-0.11.fc15.x86_64 breaks strcmp?)

2011-03-07 Thread Richard W.M. Jones
On Mon, Mar 07, 2011 at 10:14:57AM -0500, Adam Jackson wrote:
 On 3/7/11 9:49 AM, Richard W.M. Jones wrote:
 Compiling libguestfs using gcc-4.6.0-0.11.fc15.x86_64 gives lots of:
 
 error: assuming signed overflow does not occur when changing X +- C1
 cmp C2 to X cmp C1 +- C2 [-Werror=strict-overflow]
 
 These seem to be associated with code that does 'if (strcmp (s1, s2)
 == 0)'
 
 For example:
 
 dir.c: In function ‘do_rm_rf’: dir.c:59:7: error: assuming signed
 overflow does not occur when changing X +- C1 cmp C2 to X cmp C1 +-
 C2 [-Werror=strict-overflow]
 
 I'm not able to repro this with -0.12.fc15.

Firstly, I have just installed -0.12 and I can reproduce it.

 If I had to guess,
 you've got a macro for strcmp somewhere that's making type
 assumptions.  What does the .i file look like if you compile with
 -save-temps ?

OK ... When you said that, I initially suspected gnulib (which I am
using in this code), but I cannot see gnulib doing any macros or
replacement of strcmp.

Below is how the failure line expands(!)

--
  if ((__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p 
((path))  __builtin_constant_p ((/))  (__s1_len = strlen ((path)), 
__s2_len = strlen ((/)), (!((size_t)(const void *)(((path)) + 1) - 
(size_t)(const void *)((path)) == 1) || __s1_len = 4)  (!((size_t)(const 
void *)(((/)) + 1) - (size_t)(const void *)((/)) == 1) || __s2_len = 4)) ? 
__builtin_strcmp ((path), (/)) : (__builtin_constant_p ((path))  
((size_t)(const void *)(((path)) + 1) - (size_t)(const void *)((path)) == 1)  
(__s1_len = strlen ((path)), __s1_len  4) ? (__builtin_constant_p ((/))  
((size_t)(const void *)(((/)) + 1) - (size_t)(const void *)((/)) == 1) ? 
__builtin_strcmp ((path), (/)) : (__extension__ ({ __const unsigned char 
*__s2 = (__const unsigned char *) (__const char *) ((/)); register int 
__result = (((__const unsigned char *) (__const char *) ((path)))[0] - 
__s2[0]); if (__s1_len  0  __result == 0) { __result = (((__const unsigned 
char *) (__const char *) ((path)))[1] - __s2[1]); if (__s1_len  1  __result 
== 0) { __result = (((__const unsigned char *) (__const char *) ((path)))[2] - 
__s2[2]); if (__s1_len  2  __result == 0) __result = (((__const unsigned 
char *) (__const char *) ((path)))[3] - __s2[3]); } } __result; }))) : 
(__builtin_constant_p ((/))  ((size_t)(const void *)(((/)) + 1) - 
(size_t)(const void *)((/)) == 1)  (__s2_len = strlen ((/)), __s2_len  
4) ? (__builtin_constant_p ((path))  ((size_t)(const void *)(((path)) + 1) - 
(size_t)(const void *)((path)) == 1) ? __builtin_strcmp ((path), (/)) : 
(__extension__ ({ __const unsigned char *__s1 = (__const unsigned char *) 
(__const char *) ((path)); register int __result = __s1[0] - ((__const unsigned 
char *) (__const char *) ((/)))[0]; if (__s2_len  0  __result == 0) { 
__result = (__s1[1] - ((__const unsigned char *) (__const char *) ((/)))[1]); 
if (__s2_len  1  __result == 0) { __result = (__s1[2] - ((__const unsigned 
char *) (__const char *) ((/)))[2]); if (__s2_len  2  __result == 0) 
__result = (__s1[3] - ((__const unsigned char *) (__const char *) ((/)))[3]); 
} } __result; }))) : __builtin_strcmp ((path), (/); }) == 0)) {
--

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel

Re: gcc-4.6.0-0.11.fc15.x86_64 breaks strcmp?

2011-03-07 Thread yersinia
On Mon, Mar 7, 2011 at 3:49 PM, Richard W.M. Jones rjo...@redhat.com wrote:
 Compiling libguestfs using gcc-4.6.0-0.11.fc15.x86_64 gives lots of:

 error: assuming signed overflow does not occur when changing X +- C1 cmp C2 
 to X cmp C1 +- C2 [-Werror=strict-overflow]

 These seem to be associated with code that does 'if (strcmp (s1, s2) == 0)'

 For example:

 dir.c: In function ‘do_rm_rf’:
 dir.c:59:7: error: assuming signed overflow does not occur when changing X +- 
 C1 cmp C2 to X cmp C1 +- C2 [-Werror=strict-overflow]

 --
 int
 do_rm_rf (const char *path)
 {
  int r;
  char *buf, *err;

  if (STREQ (path, /)) {                      -- here
    reply_with_error (cannot remove root directory);
    return -1;
  }
 --

 where STREQ is a simple macro:

 #define STREQ(a,b) (strcmp((a),(b)) == 0)

I remeber that gnu lib have a similar macro, and last year there was a
fix  
http://old.nabble.com/-PATCH--define-STREQ%28a,-b%29-consistently,-removing-useless-parentheses-td27293621.html

But also in libvirt apparently
http://www.redhat.com/archives/libvir-list/2010-February/msg00010.html

Dunno if this if OT or no

Regards

Regards

Regards

 AFAIK this code should be correct?  I can't find anything at all about
 this specific error from Google.

 Rich.

 --
 Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
 virt-p2v converts physical machines to virtual machines.  Boot with a
 live CD or over the network (PXE) and turn machines into Xen guests.
 http://et.redhat.com/~rjones/virt-p2v
 --
 devel mailing list
 devel@lists.fedoraproject.org
 https://admin.fedoraproject.org/mailman/listinfo/devel
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel


Re: gcc-4.6.0-0.11.fc15.x86_64 breaks strcmp?

2011-03-07 Thread Richard W.M. Jones
On Mon, Mar 07, 2011 at 04:37:20PM +0100, yersinia wrote:
 I remeber that gnu lib have a similar macro, and last year there was a
 fix  
 http://old.nabble.com/-PATCH--define-STREQ%28a,-b%29-consistently,-removing-useless-parentheses-td27293621.html

I understand Jim's argument, although I think I'd rather leave those
parentheses in for safety.

In any case, I tried it without them and as expected it didn't make
any difference to this problem.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel


Re: gcc-4.6.0-0.11.fc15.x86_64 breaks strcmp?

2011-03-07 Thread Jim Meyering
Richard W.M. Jones wrote:
 Compiling libguestfs using gcc-4.6.0-0.11.fc15.x86_64 gives lots of:

 error: assuming signed overflow does not occur when changing X +- C1 cmp C2 
 to X cmp C1 +- C2 [-Werror=strict-overflow]

 These seem to be associated with code that does 'if (strcmp (s1, s2) == 0)'

 For example:

 dir.c: In function ‘do_rm_rf’:
 dir.c:59:7: error: assuming signed overflow does not occur when changing X +- 
 C1 cmp C2 to X cmp C1 +- C2 [-Werror=strict-overflow]

 --
 int
 do_rm_rf (const char *path)
 {
   int r;
   char *buf, *err;

   if (STREQ (path, /)) {  -- here
 reply_with_error (cannot remove root directory);
 return -1;
   }
 --

 where STREQ is a simple macro:

 #define STREQ(a,b) (strcmp((a),(b)) == 0)

 AFAIK this code should be correct?  I can't find anything at all about
 this specific error from Google.

Hi Rich,

I suspect that there was a problem with .11, perhaps one of these:

* Fri Mar 04 2011 Jakub Jelinek ja...@redhat.com 4.6.0-0.12
- update from trunk
  - PRs c++/46159, c++/46282, c++/47200, c++/47774, c++/47851, c++/47950,
c++/47974, c/47963, libstdc++/47913, middle-end/47283,
rtl-optimization/47925, target/47935, tree-optimization/47890
- rebuilt against ppl 0.11.2, reenable cloog-ppl Requires

because I can't reproduce that with the latest in rawhide,
gcc-4.6.0-0.12.fc15.x86_64:

$ cat k.c  :
#define STREQ(a,b) (strcmp((a),(b)) == 0)

int
do_rm_rf (const char *path)
{
  int r;
  char *buf, *err;

  if (STREQ (path, /))
{
  reply_with_error (cannot remove root directory);
  return -1;
}
}
$ gcc -O3 -c k.c -Werror=strict-overflow   :
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel

Re: gcc-4.6.0-0.11.fc15.x86_64 breaks strcmp?

2011-03-07 Thread Jakub Jelinek
On Mon, Mar 07, 2011 at 05:09:17PM +0100, Jim Meyering wrote:
 I suspect that there was a problem with .11, perhaps one of these:
 
 * Fri Mar 04 2011 Jakub Jelinek ja...@redhat.com 4.6.0-0.12
 - update from trunk
   - PRs c++/46159, c++/46282, c++/47200, c++/47774, c++/47851, c++/47950,
 c++/47974, c/47963, libstdc++/47913, middle-end/47283,
 rtl-optimization/47925, target/47935, tree-optimization/47890
 - rebuilt against ppl 0.11.2, reenable cloog-ppl Requires
 
 because I can't reproduce that with the latest in rawhide,
 gcc-4.6.0-0.12.fc15.x86_64:

You forgot to #include string.h

 $ cat k.c 
  :
 #define STREQ(a,b) (strcmp((a),(b)) == 0)
 
 int
 do_rm_rf (const char *path)
 {
   int r;
   char *buf, *err;
 
   if (STREQ (path, /))
 {
   reply_with_error (cannot remove root directory);
   return -1;
 }
 }
 $ gcc -O3 -c k.c -Werror=strict-overflow  
  :

I can reproduce it and have filed http://gcc.gnu.org/PR48022 for it.

Jakub
-- 
devel mailing list
devel@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/devel