[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#774118: libc6:amd64: strspn generates compiler warning



Package: libc6
Version: 2.13-38+deb7u4
Severity: normal

A compiler warning message is generated by the following
test code and compiler options.

irwin@raven> cat >test_strspn.c
#include <stdio.h>
#include <string.h>
int
main(void) {
  strcmp("  8998797857586fasdfljf", " ");
  strspn("  8998797857586fasdfljf", " ");
  strcspn("  8998797857586fasdfljf", " ");
  return 0;
}
^D
irwin@raven> gcc -O1 -Wconversion test_strspn.c
test_strspn.c: In function ‘main’:
test_strspn.c:6:3: warning: conversion to ‘long unsigned int’ from
‘int’ may change the sign of the result [-Wsign-conversion]

Note the warning message only occurs for line 6, and does not occur
for the very similar line 5 and line 7.  In particular, strcspn has
the exact same return type, argument types, and number of arguments as
strspn, yet strspn generates the warning while strcspn does not.
Therefore, I am pretty sure this warning is due to some difference in
how the strspn and strcspn arguments or returns are defined in libc6
when those should be absolutely identical between the two functions.
That difference (as well as the warning itself about transformation
from int to long unsigned int) is a cause for concern about the
reliability of strspn.  So I hope to see vigorous follow up. 

-- System Information:
Debian Release: 7.6
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libc6:amd64 depends on:
ii  libc-bin  2.13-38+deb7u4
ii  libgcc1   1:4.7.2-5

libc6:amd64 recommends no packages.

Versions of packages libc6:amd64 suggests:
ii  debconf [debconf-2.0]  1.5.49
ii  glibc-doc              2.13-38+deb7u4
ii  locales                2.13-38+deb7u4

-- debconf information:
  glibc/upgrade: true
  glibc/restart-services:
* libraries/restart-without-asking: false
  glibc/disable-screensaver:
  glibc/restart-failed:


Reply to: