public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66177] New: warn_unused_result doesn't always work
@ 2015-05-16 15:00 gcc at bobbyperu dot info
  2015-05-16 15:23 ` [Bug c++/66177] " gcc at bobbyperu dot info
  0 siblings, 1 reply; 2+ messages in thread
From: gcc at bobbyperu dot info @ 2015-05-16 15:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66177

            Bug ID: 66177
           Summary: warn_unused_result doesn't always work
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at bobbyperu dot info
  Target Milestone: ---

Testcase fails to work with gcc, works with clang.

=====
struct QSize
{
    QSize(int w, int h) : wd(w), ht(h) {}

    QSize expandedTo() const __attribute__ ((__warn_unused_result__))
    {
        return QSize(2, 3);
    }

private:
    int wd;
    int ht;
};

void foo()
{
    QSize sz(2, 2);
    sz.expandedTo();
}
=====
$ g++ testcase.cpp -c -Wunused-result

$ clang++ testcase.cpp -c -Wunused-result
testcase.cpp:18:5: warning: ignoring return value of function declared with
warn_unused_result attribute [-Wunused-result]
    sz.expandedTo();
    ^~~~~~~~~~~~~
1 warning generated.


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

* [Bug c++/66177] warn_unused_result doesn't always work
  2015-05-16 15:00 [Bug c++/66177] New: warn_unused_result doesn't always work gcc at bobbyperu dot info
@ 2015-05-16 15:23 ` gcc at bobbyperu dot info
  0 siblings, 0 replies; 2+ messages in thread
From: gcc at bobbyperu dot info @ 2015-05-16 15:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66177

--- Comment #1 from Sergio Martins <gcc at bobbyperu dot info> ---
It this is known, at least please mention in the documentation it only works
for built-in types.


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

end of thread, other threads:[~2015-05-16 15:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-16 15:00 [Bug c++/66177] New: warn_unused_result doesn't always work gcc at bobbyperu dot info
2015-05-16 15:23 ` [Bug c++/66177] " gcc at bobbyperu dot info

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