public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/31063]  New: Spurrious/missing warn_unused_result warnings affected by presence/absense of copy constructor
@ 2007-03-06 22:23 fletcherdunn at yahoo dot com
  2007-03-06 22:26 ` [Bug c++/31063] " fletcherdunn at yahoo dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: fletcherdunn at yahoo dot com @ 2007-03-06 22:23 UTC (permalink / raw)
  To: gcc-bugs

// Illustrates some bugs related to __attribute__((warn_unused_result)).

struct Vector {
        float x, y, z;
        inline Vector() {}
        inline Vector(float _x,float _y,float _z) : x(_x), y(_y), z(_z) {}

        // BUG: Toggling the presence of a copy constructor (doesn't matter
which
        // of the ones below you use) will affect the generation of the
warnings.
        inline Vector(const Vector &a) { x = a.x; y = a.y; z = a.z; }
//      inline Vector(const Vector &a) : x(a.x), y(a.y), z(a.z) {}

        inline Vector operator-(const Vector &a) const
__attribute__((warn_unused_result)) {
                return Vector(x - a.x, y - a.y, z - a.z );
        }
};

struct Box {
        Vector min, max;

        // BUG: generates spurrious warning about not using result from
operator-.
        // If you remove the copy constructor, the warning goes away
        inline Vector size() const { return max - min; }
};

void foo() {
        Vector a, b;

        // BUG: this *should* generate a warning, but you will only get a
warning
        // if you have the copy constructor.  If you remove the copy
constructor,
        // the warning goes away
        a-b;
}

//
// Output with copy constructor defined:
//
//   $ /c/usr/local/cell/host-win32/ppu/ppu-lv2/bin/gcc -v -save-temps -c -Wall
warn_unused_result_bug_2.cpp
//   Using built-in specs.
//   Target: ppu-lv2
//   Configured with: /export/fukuoka/ps3-svn/toolchain/trunk/gcc/configure
--target=ppu-lv2 --host=i386-pc-mingw32msvc --build=i686-pc-linux-gnu
--prefix=/usr/local/cell/host-win32/ppu
--with-sysroot=/usr/local/cell/target/ppu --with-headers=yes --disable-threads
--disable-shared --disable-hosted-libstdcxx
//   Thread model: single
//   gcc version 4.0.2 (CELL 4.1.19, $Rev: 1341 $)
//    /usr/local/cell/host-win32/ppu/libexec/gcc/ppu-lv2/4.0.2/cc1plus.exe -E
-quiet -v -iprefix
c:\usr\local\cell\host-win32\ppu\ppu-lv2\bin\../lib/gcc/ppu-lv2/4.0.2/
-D__PPU__ -D__CELLOS_LV2__ warn_unused_result_bug_2.cpp -mabi=altivec -maltivec
-mstrict-align -fstrict-aligned -mvrsave=no -mtraceback=none -Wall
-fpch-preprocess -fno-threadsafe-statics -o warn_unused_result_bug_2.ii
//   ignoring nonexistent directory
"c:/usr/local/cell/host-win32/ppu/ppu-lv2/bin/../lib/gcc/ppu-lv2/4.0.2/include"
//   #include "..." search starts here:
//   #include <...> search starts here:
//    /usr/local/cell/host-win32/ppu/lib/gcc/ppu-lv2/4.0.2/include
//    /usr/local/cell/target/ppu/include
//    /usr/local/cell/target/ppu/include/sys
//    /usr/local/cell/target/ppu/../common/include
//   End of search list.
//    /usr/local/cell/host-win32/ppu/libexec/gcc/ppu-lv2/4.0.2/cc1plus.exe
-fpreprocessed warn_unused_result_bug_2.ii -mabi=altivec -maltivec
-mstrict-align -fstrict-aligned -mvrsave=no -mtraceback=none -quiet -dumpbase
warn_unused_result_bug_2.cpp -auxbase warn_unused_result_bug_2 -Wall -version
-fno-threadsafe-statics -o warn_unused_result_bug_2.s
//   GNU C++ version 4.0.2 (CELL 4.1.19, $Rev: 1341 $) (ppu-lv2)
//           compiled by GNU C version 4.0.2 (CELL 4.1.19, $Rev: 1341 $).
//   GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=130941
//   warn_unused_result_bug_2.cpp: In member function 'Vector Box::size()
const':
//   warn_unused_result_bug_2.cpp:23: warning: ignoring return value of 'Vector
Vector::operator-(const Vector&) const', declared with attribute
warn_unused_result
//   warn_unused_result_bug_2.cpp: In function 'void foo()':
//   warn_unused_result_bug_2.cpp:32: warning: ignoring return value of 'Vector
Vector::operator-(const Vector&) const', declared with attribute
warn_unused_result
//
// If you comment out the copy constructor, the warnings do not appear.
// Note that I produced this with the Playstation (CELL) version of GCC under
// MinGW/MSys, but I don't think this is a platform specific issues.
//
// gccc --version produces this:
// gcc.exe (GCC) 4.0.2 (CELL 4.1.19, $Rev: 1341 $)
// Copyright (C) 2005 Free Software Foundation, Inc.
// This is free software; see the source for copying conditions.  There is NO
// warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// This might be a dup of either of these issues:
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27370
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27371
//
// Cheers,
// fletcherdunn --at-- yahoo.com
//


-- 
           Summary: Spurrious/missing warn_unused_result warnings affected
                    by presence/absense of copy constructor
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fletcherdunn at yahoo dot com


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


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

* [Bug c++/31063] Spurrious/missing warn_unused_result warnings affected by presence/absense of copy constructor
  2007-03-06 22:23 [Bug c++/31063] New: Spurrious/missing warn_unused_result warnings affected by presence/absense of copy constructor fletcherdunn at yahoo dot com
@ 2007-03-06 22:26 ` fletcherdunn at yahoo dot com
  2007-03-06 22:41 ` pinskia at gcc dot gnu dot org
  2008-11-18 22:16 ` [Bug c++/31063] Spurious/missing " pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: fletcherdunn at yahoo dot com @ 2007-03-06 22:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from fletcherdunn at yahoo dot com  2007-03-06 22:26 -------
Created an attachment (id=13155)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13155&action=view)
Repro code with the proper line breaks

Line breaks got messed up when pasting into bug description.


-- 


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


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

* [Bug c++/31063] Spurrious/missing warn_unused_result warnings affected by presence/absense of copy constructor
  2007-03-06 22:23 [Bug c++/31063] New: Spurrious/missing warn_unused_result warnings affected by presence/absense of copy constructor fletcherdunn at yahoo dot com
  2007-03-06 22:26 ` [Bug c++/31063] " fletcherdunn at yahoo dot com
@ 2007-03-06 22:41 ` pinskia at gcc dot gnu dot org
  2008-11-18 22:16 ` [Bug c++/31063] Spurious/missing " pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-06 22:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2007-03-06 22:40 -------
// If you comment out the copy constructor, the warnings do not appear.
// Note that I produced this with the Playstation (CELL) version of GCC under
// MinGW/MSys, but I don't think this is a platform specific issues.

You should have filed this first with Sony.  We (Sony) do change the bug
reporting address to the correct one for the PS3 toolchain.

Thanks,
Andrew Pinski
Sony Compiler Engineer


-- 


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


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

* [Bug c++/31063] Spurious/missing warn_unused_result warnings affected by presence/absense of copy constructor
  2007-03-06 22:23 [Bug c++/31063] New: Spurrious/missing warn_unused_result warnings affected by presence/absense of copy constructor fletcherdunn at yahoo dot com
  2007-03-06 22:26 ` [Bug c++/31063] " fletcherdunn at yahoo dot com
  2007-03-06 22:41 ` pinskia at gcc dot gnu dot org
@ 2008-11-18 22:16 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-11-18 22:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2008-11-18 22:14 -------
PR 38172 has the better example.

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


-- 

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=31063


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

end of thread, other threads:[~2008-11-18 22:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-06 22:23 [Bug c++/31063] New: Spurrious/missing warn_unused_result warnings affected by presence/absense of copy constructor fletcherdunn at yahoo dot com
2007-03-06 22:26 ` [Bug c++/31063] " fletcherdunn at yahoo dot com
2007-03-06 22:41 ` pinskia at gcc dot gnu dot org
2008-11-18 22:16 ` [Bug c++/31063] Spurious/missing " 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).