public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/22207] New: Spurious 'might be used uninitialized' warnings in STL headers with -O2
@ 2005-06-27 23:08 brian at dessent dot net
  2005-06-27 23:10 ` [Bug libstdc++/22207] " brian at dessent dot net
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: brian at dessent dot net @ 2005-06-27 23:08 UTC (permalink / raw)
  To: gcc-bugs

The following reduced test case causes spurious -Wuninitialized warnings, but
only with -O2:

-----

#include <vector>
#include <string>

class OptionSet
{
public:
  OptionSet ();
  std::vector<std::string> const &nonOptions() const;
private:
  std::vector<std::string> nonoptions;
};

OptionSet::OptionSet()
{
  nonoptions = std::vector<std::string> ();
}

std::vector<std::string> const &
OptionSet::nonOptions() const
{
  return nonoptions;
}

-----

$ g++ -Wuninitialized -O2 -c spurious_uninitialized_testcase.cc
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_vector.h: In member
function `std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const
std::vector<_Tp, _Alloc>&) [with _Tp = std::string, _Alloc =
std::allocator<std::string>]':
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_vector.h:715: warning:
'__result' might be used uninitialized in this function
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82:
warning: '__cur' might be used uninitialized in this function
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_uninitialized.h:82:
warning: '__cur' might be used uninitialized in this function

$ g++ -v
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose --prefix=/usr
--exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--enable-languages=c,ada,c++,d,f77,java,objc --enable-nls
--without-included-gettext --enable-version-specific-runtime-libs --without-x
--enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter
--disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm
--disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization
--enable-libstdcxx-debug : (reconfigured) 
Thread model: posix
gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)

-----

The warnings only occur at -O2 and seem to have something to do with inlining. 
This causes our build that uses "-Wall -Werror" to die whereas it had no problem
with this warning in gcc-3.3.

I'm sensitive to the fact that it's impossible for the compiler to get this
warning correct every time, and the reason for the use of "might be" in the
warning text.  It's acceptible to emit warnings about things that may not
actually be the case, and normally I would just modify the build environment to
disable that warning or lose -Werror.  But in this case, the code in question is
in the STL and is completely out of the hands of the user, and I don't think
it's unreasonable to expect to be able to compile STL-based code with -Werror -Wall.

-- 
           Summary: Spurious 'might be used uninitialized' warnings in STL
                    headers with -O2
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: brian at dessent dot net
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-cygwin


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


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

* [Bug libstdc++/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
  2005-06-27 23:08 [Bug libstdc++/22207] New: Spurious 'might be used uninitialized' warnings in STL headers with -O2 brian at dessent dot net
@ 2005-06-27 23:10 ` brian at dessent dot net
  2005-06-27 23:15 ` [Bug middle-end/22207] " pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: brian at dessent dot net @ 2005-06-27 23:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From brian at dessent dot net  2005-06-27 23:10 -------
Created an attachment (id=9163)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=9163&action=view)
Preprocessed source for testcase


-- 


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
  2005-06-27 23:08 [Bug libstdc++/22207] New: Spurious 'might be used uninitialized' warnings in STL headers with -O2 brian at dessent dot net
  2005-06-27 23:10 ` [Bug libstdc++/22207] " brian at dessent dot net
@ 2005-06-27 23:15 ` pinskia at gcc dot gnu dot org
  2005-09-06 11:07 ` dave dot korn at artimi dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-27 23:15 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|libstdc++                   |middle-end
   GCC host triplet|i686-pc-cygwin              |
 GCC target triplet|                            |i686-pc-cygwin
           Keywords|                            |diagnostic


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
  2005-06-27 23:08 [Bug libstdc++/22207] New: Spurious 'might be used uninitialized' warnings in STL headers with -O2 brian at dessent dot net
  2005-06-27 23:10 ` [Bug libstdc++/22207] " brian at dessent dot net
  2005-06-27 23:15 ` [Bug middle-end/22207] " pinskia at gcc dot gnu dot org
@ 2005-09-06 11:07 ` dave dot korn at artimi dot com
  2005-09-06 11:28 ` james at juranfamily dot org
  2005-09-06 18:59 ` ian at airs dot com
  4 siblings, 0 replies; 15+ messages in thread
From: dave dot korn at artimi dot com @ 2005-09-06 11:07 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dave dot korn at artimi dot
                   |                            |com


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
  2005-06-27 23:08 [Bug libstdc++/22207] New: Spurious 'might be used uninitialized' warnings in STL headers with -O2 brian at dessent dot net
                   ` (2 preceding siblings ...)
  2005-09-06 11:07 ` dave dot korn at artimi dot com
@ 2005-09-06 11:28 ` james at juranfamily dot org
  2005-09-06 18:59 ` ian at airs dot com
  4 siblings, 0 replies; 15+ messages in thread
From: james at juranfamily dot org @ 2005-09-06 11:28 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |james at juranfamily dot org


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
  2005-06-27 23:08 [Bug libstdc++/22207] New: Spurious 'might be used uninitialized' warnings in STL headers with -O2 brian at dessent dot net
                   ` (3 preceding siblings ...)
  2005-09-06 11:28 ` james at juranfamily dot org
@ 2005-09-06 18:59 ` ian at airs dot com
  4 siblings, 0 replies; 15+ messages in thread
From: ian at airs dot com @ 2005-09-06 18:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From ian at airs dot com  2005-09-06 18:59 -------
Confirmed that this happens with 3.4 for the i686-pc-cygwin target, though not
for the i686-pc-linux-gnu target.  It is fixed in current mainline for both targets.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ian at airs dot com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |3.4.4
      Known to work|                            |4.1.0
   Last reconfirmed|0000-00-00 00:00:00         |2005-09-06 18:59:23
               date|                            |


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
       [not found] <bug-22207-10678@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2008-10-03 12:55 ` pdemarco at ppg dot com
@ 2008-10-03 13:01 ` paolo dot carlini at oracle dot com
  8 siblings, 0 replies; 15+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-03 13:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from paolo dot carlini at oracle dot com  2008-10-03 13:00 -------
Brian is right:

  http://gcc.gnu.org/mirrors.html


-- 


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
       [not found] <bug-22207-10678@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2008-10-01 20:27 ` brian at dessent dot net
@ 2008-10-03 12:55 ` pdemarco at ppg dot com
  2008-10-03 13:01 ` paolo dot carlini at oracle dot com
  8 siblings, 0 replies; 15+ messages in thread
From: pdemarco at ppg dot com @ 2008-10-03 12:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from pdemarco at ppg dot com  2008-10-03 12:53 -------
(In reply to comment #9)
> Subject: Re:  Spurious 'might be used uninitialized' 
>  warnings in STL headers with -O2
> You are confusing the state of the Cygwin port of gcc with gcc in
> general.

Possibly, but I cannot find the download for 4.x.x.
Why does it have to be so confusing ?

http://sourceforge.net/project/showfiles.php?group_id=2435

This is the location that I got ALPHA from.
It appears that the best 4.x.x download is: Testing:
gcc-4.3.0-20080502-mingw32-alpha

I see no other reasonable downloads.


-- 


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
       [not found] <bug-22207-10678@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2008-10-01 18:20 ` pdemarco at ppg dot com
@ 2008-10-01 20:27 ` brian at dessent dot net
  2008-10-03 12:55 ` pdemarco at ppg dot com
  2008-10-03 13:01 ` paolo dot carlini at oracle dot com
  8 siblings, 0 replies; 15+ messages in thread
From: brian at dessent dot net @ 2008-10-01 20:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from brian at dessent dot net  2008-10-01 20:25 -------
Subject: Re:  Spurious 'might be used uninitialized' 
 warnings in STL headers with -O2

You are confusing the state of the Cygwin port of gcc with gcc in
general.


-- 


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
       [not found] <bug-22207-10678@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2008-10-01 18:19 ` paolo dot carlini at oracle dot com
@ 2008-10-01 18:20 ` pdemarco at ppg dot com
  2008-10-01 20:27 ` brian at dessent dot net
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: pdemarco at ppg dot com @ 2008-10-01 18:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pdemarco at ppg dot com  2008-10-01 18:19 -------
(In reply to comment #7)
> (In reply to comment #6)
> > okay, but I wish that you wouldn't freeze 3.x when 4.x is still in Alpha.
> Alpha?!? What do you mean, exactly? Certainly we have a very stable 4.3.x
> release series, and previously we had 4.2.x, and previously 4.1.x...

My understanding was that 4.x was not available.  I'll have to re-check.  sorry
for the noise.


-- 


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
       [not found] <bug-22207-10678@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2008-10-01 18:05 ` pdemarco at ppg dot com
@ 2008-10-01 18:19 ` paolo dot carlini at oracle dot com
  2008-10-01 18:20 ` pdemarco at ppg dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: paolo dot carlini at oracle dot com @ 2008-10-01 18:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from paolo dot carlini at oracle dot com  2008-10-01 18:17 -------
(In reply to comment #6)
> okay, but I wish that you wouldn't freeze 3.x when 4.x is still in Alpha.

Alpha?!? What do you mean, exactly? Certainly we have a very stable 4.3.x
release series, and previously we had 4.2.x, and previously 4.1.x...




-- 


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
       [not found] <bug-22207-10678@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2008-10-01 14:20 ` dave dot korn at artimi dot com
@ 2008-10-01 18:05 ` pdemarco at ppg dot com
  2008-10-01 18:19 ` paolo dot carlini at oracle dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: pdemarco at ppg dot com @ 2008-10-01 18:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pdemarco at ppg dot com  2008-10-01 18:04 -------
(In reply to comment #5)
> Sorry mate, all 3.x compilers are way past end-of-life now; there will never be
> another release.
okay, but I wish that you wouldn't freeze 3.x when 4.x is still in Alpha.  If I
could upgrade to a stable 4.x for the change... I would.


-- 


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
       [not found] <bug-22207-10678@http.gcc.gnu.org/bugzilla/>
  2006-03-08 16:06 ` pinskia at gcc dot gnu dot org
  2008-10-01 12:12 ` pdemarco at ppg dot com
@ 2008-10-01 14:20 ` dave dot korn at artimi dot com
  2008-10-01 18:05 ` pdemarco at ppg dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: dave dot korn at artimi dot com @ 2008-10-01 14:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dave dot korn at artimi dot com  2008-10-01 14:19 -------
Sorry mate, all 3.x compilers are way past end-of-life now; there will never be
another release.

Your best bet is to hand-edit the header files in your local install.  I don't
remember the exact recipe, but of the two places where this bug crops up, one
can be worked around by adding "__attribute__ ((__unused__))" to the relevant
variable declaration, and the other one has to be fixed by adding
"__attribute__ ((__noinline__))" to the function declaration.

I haven't tested these workaround for performance impact.  Shouldn't be too bad
if you're not calling the functions from the middle of a loop that runs
millions of times.


-- 


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
       [not found] <bug-22207-10678@http.gcc.gnu.org/bugzilla/>
  2006-03-08 16:06 ` pinskia at gcc dot gnu dot org
@ 2008-10-01 12:12 ` pdemarco at ppg dot com
  2008-10-01 14:20 ` dave dot korn at artimi dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: pdemarco at ppg dot com @ 2008-10-01 12:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pdemarco at ppg dot com  2008-10-01 12:10 -------
any chance of getting this fixed on 3.4.4 ???


-- 


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


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

* [Bug middle-end/22207] Spurious 'might be used uninitialized' warnings in STL headers with -O2
       [not found] <bug-22207-10678@http.gcc.gnu.org/bugzilla/>
@ 2006-03-08 16:06 ` pinskia at gcc dot gnu dot org
  2008-10-01 12:12 ` pdemarco at ppg dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-08 16:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-03-08 16:06 -------
Fixed in 4.0.0.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.0.0


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


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

end of thread, other threads:[~2008-10-03 13:01 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-27 23:08 [Bug libstdc++/22207] New: Spurious 'might be used uninitialized' warnings in STL headers with -O2 brian at dessent dot net
2005-06-27 23:10 ` [Bug libstdc++/22207] " brian at dessent dot net
2005-06-27 23:15 ` [Bug middle-end/22207] " pinskia at gcc dot gnu dot org
2005-09-06 11:07 ` dave dot korn at artimi dot com
2005-09-06 11:28 ` james at juranfamily dot org
2005-09-06 18:59 ` ian at airs dot com
     [not found] <bug-22207-10678@http.gcc.gnu.org/bugzilla/>
2006-03-08 16:06 ` pinskia at gcc dot gnu dot org
2008-10-01 12:12 ` pdemarco at ppg dot com
2008-10-01 14:20 ` dave dot korn at artimi dot com
2008-10-01 18:05 ` pdemarco at ppg dot com
2008-10-01 18:19 ` paolo dot carlini at oracle dot com
2008-10-01 18:20 ` pdemarco at ppg dot com
2008-10-01 20:27 ` brian at dessent dot net
2008-10-03 12:55 ` pdemarco at ppg dot com
2008-10-03 13:01 ` paolo dot carlini at oracle dot com

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).