public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40114]  New: Incomplete flow analysis in template produces spurious diagnostic
@ 2009-05-12 11:13 gowen at innovative-technology dot co dot uk
  2009-05-12 14:50 ` [Bug c++/40114] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: gowen at innovative-technology dot co dot uk @ 2009-05-12 11:13 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/40114] Incomplete flow analysis in template produces spurious diagnostic
  2009-05-12 11:13 [Bug c++/40114] New: Incomplete flow analysis in template produces spurious diagnostic gowen at innovative-technology dot co dot uk
@ 2009-05-12 14:50 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-05-12 14:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2009-05-12 14:49 -------


*** This bug has been marked as a duplicate of 4210 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-05-12 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-12 11:13 [Bug c++/40114] New: Incomplete flow analysis in template produces spurious diagnostic gowen at innovative-technology dot co dot uk
2009-05-12 14:50 ` [Bug c++/40114] " pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).