Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 659971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:06:16+00:00 2026-05-13T23:06:16+00:00

I have a section of code that can be summarised as follows; void MyFunc()

  • 0

I have a section of code that can be summarised as follows;

void MyFunc()
{
   int x;
'
'
   x;  
'
'
}

I would have thought that simply referencing a variable, without modifying it in anyway or using its value in anyway should generate a warning. In VS2003 it does neither, and it I need lint to pick it up.

I realise it doesn’t effect execution, but since it is a piece of code that does nothing, and the programmer doubtless intended to do something, why is it not flagged?

Similarly would you expect x = x to be a warning?

Edit: Modified question, as this constitutes a good candidate for a warning, but is not an error. Replies suggest this is handled better with other compilers. Will try out VS2008 later and post result.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:06:17+00:00Added an answer on May 13, 2026 at 11:06 pm

    You need to use a better compiler 🙂 Compiled with the -Wall and -pedantic flags, the GCC C++ compiler given this code:

    int main() {
        int x = 0;
        x;
    }
    

    produces this diagnostic:

    ma.cpp:3: warning: statement has no effect
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following section of code. Is there anyway that I can use
I have a section of code that I would not like to run if
I have a section of PHP code that I would like to place in
I have the following section of code in an app that I am writing:
I have some very simple code below that I can't get to validate on
I have a section of code that I need to remove from multiple files
I have a section of code that sends email from SMTP server. The code
Interesting situation. I have a section of code that creates several ZipOutputStreams. As a
I have the following section of code that acts on values in <Test></Test> nodes
In my Django application, I have a section of code that uploads a file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.