public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/27370]  New: Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result)))
@ 2006-05-01 15:18 rguenth at gcc dot gnu dot org
  2006-05-01 15:19 ` [Bug c++/27370] [4.0 Regression] " rguenth at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-05-01 15:18 UTC (permalink / raw)
  To: gcc-bugs

class QByteArray {
public:
  QByteArray(const QByteArray &);
};
class QString {
  QByteArray toLocal8Bit() const __attribute__ ((warn_unused_result));
  inline QByteArray local8Bit() const{ return toLocal8Bit(); }
};

Produces with g++ -S -Wall:

test.1.1.min.ii: In member function 'QByteArray QString::local8Bit() const':
test.1.1.min.ii:7: warning: ignoring return value of 'QByteArray
QString::toLocal8Bit() const', declared with attribute warn_unused_result


-- 
           Summary: Bogus warning about ignoring function return value
                    (__attribute__ ((warn_unused_result)))
           Product: gcc
           Version: 4.0.3
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


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

* [Bug c++/27370] [4.0 Regression] Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result)))
  2006-05-01 15:18 [Bug c++/27370] New: Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result))) rguenth at gcc dot gnu dot org
@ 2006-05-01 15:19 ` rguenth at gcc dot gnu dot org
  2006-05-01 15:24 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-05-01 15:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2006-05-01 15:19 -------
A regression from 3.4.6.  Works in 4.1.0 - Janis, can you hunt this down?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.0.3
      Known to work|                            |3.4.6 4.1.0
            Summary|Bogus warning about ignoring|[4.0 Regression] Bogus
                   |function return value       |warning about ignoring
                   |(__attribute__              |function return value
                   |((warn_unused_result)))     |(__attribute__
                   |                            |((warn_unused_result)))


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


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

* [Bug c++/27370] [4.0 Regression] Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result)))
  2006-05-01 15:18 [Bug c++/27370] New: Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result))) rguenth at gcc dot gnu dot org
  2006-05-01 15:19 ` [Bug c++/27370] [4.0 Regression] " rguenth at gcc dot gnu dot org
@ 2006-05-01 15:24 ` rguenth at gcc dot gnu dot org
  2006-05-01 15:26 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-05-01 15:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2006-05-01 15:24 -------
Though 4.1.0 seems to not warn at all:

class QByteArray {
public:
  QByteArray(const QByteArray &);
};
class QString {
  QByteArray toLocal8Bit() const __attribute__ ((warn_unused_result));
  inline QByteArray local8Bit() const{ return toLocal8Bit(); }
  void fooWarnHere() const { toLocal8Bit(); }
};

should warn for fooWarnHere, but doesn't.


-- 


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


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

* [Bug c++/27370] [4.0 Regression] Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result)))
  2006-05-01 15:18 [Bug c++/27370] New: Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result))) rguenth at gcc dot gnu dot org
  2006-05-01 15:19 ` [Bug c++/27370] [4.0 Regression] " rguenth at gcc dot gnu dot org
  2006-05-01 15:24 ` rguenth at gcc dot gnu dot org
@ 2006-05-01 15:26 ` pinskia at gcc dot gnu dot org
  2006-05-02  0:09 ` janis at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-01 15:26 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor
      Known to work|3.4.6 4.1.0                 |3.4.6 4.1.0 4.2.0
   Target Milestone|---                         |4.0.4


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


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

* [Bug c++/27370] [4.0 Regression] Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result)))
  2006-05-01 15:18 [Bug c++/27370] New: Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result))) rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-05-01 15:26 ` pinskia at gcc dot gnu dot org
@ 2006-05-02  0:09 ` janis at gcc dot gnu dot org
  2006-05-02 16:15 ` janis at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: janis at gcc dot gnu dot org @ 2006-05-02  0:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from janis at gcc dot gnu dot org  2006-05-02 00:09 -------
The warning for the original testcase went away with this patch:

    r81764 | dnovillo | 2004-05-13 06:41:07 +0000 (Thu, 13 May 2004) | 3 lines  

    Merge tree-ssa-20020619-branch into mainline.

    http://gcc.gnu.org/viewcvs?view=rev&rev=81764

Ouch!  I've got another reghunt going to find out when the warning started
being issued again between 4.0 and 4.1.


-- 


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


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

* [Bug c++/27370] [4.0 Regression] Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result)))
  2006-05-01 15:18 [Bug c++/27370] New: Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result))) rguenth at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-05-02  0:09 ` janis at gcc dot gnu dot org
@ 2006-05-02 16:15 ` janis at gcc dot gnu dot org
  2006-05-04 15:25 ` rguenth at gcc dot gnu dot org
  2007-02-03 16:54 ` gdr at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: janis at gcc dot gnu dot org @ 2006-05-02 16:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from janis at gcc dot gnu dot org  2006-05-02 16:14 -------
The warning was issued again with this patch:

    http://gcc.gnu.org/viewcvs?view=rev&rev=101269

    r101269 | jason | 2005-06-23 14:44:21 +0000 (Thu, 23 Jun 2005)


-- 


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


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

* [Bug c++/27370] [4.0 Regression] Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result)))
  2006-05-01 15:18 [Bug c++/27370] New: Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result))) rguenth at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-05-02 16:15 ` janis at gcc dot gnu dot org
@ 2006-05-04 15:25 ` rguenth at gcc dot gnu dot org
  2007-02-03 16:54 ` gdr at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-05-04 15:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2006-05-04 15:25 -------
The problem with 4.0 is that the CALL_EXPR uses the return slot address to
return, but we don't honour that.

Index: c-common.c
===================================================================
*** c-common.c  (revision 113528)
--- c-common.c  (working copy)
*************** c_warn_unused_result (tree *top_p)
*** 5658,5664 ****
        break;

      case CALL_EXPR:
!       if (TREE_USED (t))
        break;

        /* This is a naked call, as opposed to a CALL_EXPR nested inside
--- 5658,5665 ----
        break;

      case CALL_EXPR:
!       if (TREE_USED (t)
!         || CALL_EXPR_HAS_RETURN_SLOT_ADDR (t))
        break;

        /* This is a naked call, as opposed to a CALL_EXPR nested inside

though this makes PR27371 also fail for 4.0, as 4.0 shares the same problem
of always emitting the "useless store".


-- 


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


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

* [Bug c++/27370] [4.0 Regression] Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result)))
  2006-05-01 15:18 [Bug c++/27370] New: Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result))) rguenth at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-05-04 15:25 ` rguenth at gcc dot gnu dot org
@ 2007-02-03 16:54 ` gdr at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: gdr at gcc dot gnu dot org @ 2007-02-03 16:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from gdr at gcc dot gnu dot org  2007-02-03 16:54 -------
Fixed in GCC-4.1.0


-- 

gdr at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.0.4                       |4.1.0


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


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

end of thread, other threads:[~2007-02-03 16:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-01 15:18 [Bug c++/27370] New: Bogus warning about ignoring function return value (__attribute__ ((warn_unused_result))) rguenth at gcc dot gnu dot org
2006-05-01 15:19 ` [Bug c++/27370] [4.0 Regression] " rguenth at gcc dot gnu dot org
2006-05-01 15:24 ` rguenth at gcc dot gnu dot org
2006-05-01 15:26 ` pinskia at gcc dot gnu dot org
2006-05-02  0:09 ` janis at gcc dot gnu dot org
2006-05-02 16:15 ` janis at gcc dot gnu dot org
2006-05-04 15:25 ` rguenth at gcc dot gnu dot org
2007-02-03 16:54 ` gdr 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).