public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: D Haley <djhaley@netspace.net.au>
To: gcc-help@gcc.gnu.org
Subject: No warning on unused variable
Date: Tue, 24 Oct 2006 05:33:00 -0000	[thread overview]
Message-ID: <453DA58F.5030706@netspace.net.au> (raw)

Hello,

I came across this situation recently

Consider the following code

#include <sstream>

using std::stringstream;

int main()
{
        int i;
        stringstream ss;
}

I the compiled it with

gcc main.cpp -Wall -lstdc++
>main.cpp: In function 'int main()':
>main.cpp:7: warning: unused variable 'i'

Why did this not warn me about the unused stringstream?
Can wall only catch unused primitive types?

Is it because the constructor is called and therefore it is not unused?
It seems that -Wall should pick this up from the point of view of "i
declared it then did nothing, this is incorrect" (also i used no params
in the constructor), but it is concievable that declaring this object
might be sufficient for some action to be taken by the code, thus
rendering it incorrect for -Wall to report it.

Is this desirable behaviour by GCC or not?

Thankyou.

             reply	other threads:[~2006-10-24  5:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-24  5:33 D Haley [this message]
2006-10-24  5:43 ` Andrew Haley
2006-10-24 14:34   ` Dave Williss
2006-10-24 17:08     ` Andrew Haley
2006-10-24 17:29 Kaz Kylheku

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=453DA58F.5030706@netspace.net.au \
    --to=djhaley@netspace.net.au \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).