http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56530

             Bug #: 56530
           Summary: Bogus warning with -Wsign-conversion (again)
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: jmatts...@dius.com.au


$ cat bogus_sign_convert_warn.cc 
#include <string>

int main (int argc, char *argv[])
{
  std::string foo[1]; // okay
  std::string bar[1][1]; // gives bogus warning
  return 0;
}

$ g++ -Wsign-conversion bogus_sign_convert_warn.cc 
bogus_sign_convert_warn.cc: In function ‘int main(int, char**)’:
bogus_sign_convert_warn.cc:6:23: warning: conversion to ‘long unsigned int’
from ‘long int’ may change the sign of the result [-Wsign-conversion]

p$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.7.2-2ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) 



This looks like a re-occurrence of bug 35602
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35602), which was fixed marked
fixed in 4.4.

Simplifying std::string down to:
 namespace std {
  struct string {
    string () {};
    ~string () {};
  };
 }
as mentioned in that bug still produces the erroneous warning.

Reply via email to