This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/40114] New: Incomplete flow analysis in template produces spurious diagnostic


Using built-in specs.
Target: mingw32
Configured with: ../gcc-4.3.3/configure --prefix=/mingw --build=mingw32
--enable-languages=c,ada,c++,fortran,objc,obj-c++
--with-bugurl=http://www.tdragon.net/recentgcc/bugs.php --disable-nls
--disable-win32-registry --enable-libgomp --disable-werror --enable-threads
--disable-symvers --enable-cxx-flags='-fno-function-sections
-fno-data-sections' --enable-fully-dynamic-string
--enable-version-specific-runtime-libs --enable-sjlj-exceptions
--with-pkgversion='4.3.3-tdm-1 mingw32'
Thread model: win32
gcc version 4.3.3 (4.3.3-tdm-1 mingw32)


The following code produces an incorrect diagnostic 
"warning: left shift count >= width of type"

template <unsigned M, unsigned N>
unsigned frob(unsigned q)
{
  if(M > N)
    return (q << (M-N));
  else
    return (q << (N-M));
}

int main()
{
  return frob<3,2> (7U);
}

This happens at -O0 and -O3, with default warnings.
Since I compile with -Werror, this is a minor pain (although it can be worked
around easily). Since M and N are template parameters, is it possible for flow
analysis to deduce that this is can not actually happen?
(The code on which this is based comes from a routine converting between fixed
point numbers with different radix position).


-- 
           Summary: Incomplete flow analysis in template produces spurious
                    diagnostic
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gowen at innovative-technology dot co dot uk
 GCC build triplet: 4.3.3-tdm-1 mingw32
  GCC host triplet: Win32
GCC target triplet: mingw32


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]