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 1099663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:46:01+00:00 2026-05-17T00:46:01+00:00

In the process of automatically renaming many variables in a big project I may

  • 0

In the process of automatically renaming many variables in a big project I may have created a lot of things like these:

class Foo {
    int Par;
    void Bar(int Par) {
        Par = Par;       // Nonsense
    }
};

Now I need to identify those locations to correct them. E.g. into “this->Par = Par;”.
Unfortunately the Visual C++ Compiler des not give me any comment about it even with all warnings on.
I remember there once was a warning about it. It said “Code has no effect” or something. But it seems to be gone maybe because some people used that practice to avoid “unreferenced parameter” warnings.
Is there a way to re-activate that warning?
Does GCC warn here?
Any Idea?

  • 1 1 Answer
  • 0 Views
  • 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-17T00:46:02+00:00Added an answer on May 17, 2026 at 12:46 am

    A couple of compilers can generate warnings on this:

    • GCC and Clang can warn on code like this if you add the -Wshadow option. (Specifically, while they don’t warn about the meaningless assignment, they do warn about the local variable Par shadowing the member variable Par – you may or may not like this.)
    • Embarcadero C++Builder does not warn that Par = Par is useless, but it can warn that Par isn’t used after it’s assigned to, which should meet your needs.

    I suspect a tool like PC-Lint could also identify code like this.

    Another solution is to mark your parameters as const:

    class Foo {
        int Par;
        void Bar(const int Par) {
            Par = Par;       // Compiler error!
        }
    };
    

    const on pass-by-value parameters is not part of the function signature, so you only need to add it to the function definitions within your .cpp file, not your function declarations within your .h file. In other words, it’s legal to do this:

    // foo.h
    class Foo {
        int Par;
        void Bar(int Par);
    };
    
    // foo.cpp
    void Foo::Bar(const int Par) { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a nightly build process that automatically versions all C++ projecs. Here's how
I'm using some PHP imap_functions to automatically process emails. However the emails have to
I'm working on a project to automatically process scanned invoices. In order get a
I have an extension that helps in submitting forms automatically for a process at
I'm trying to create a process to automatically generate thumbnails of the images uploaded
I need to automate a process whereby attachments are automatically downloaded from messages in
On a multi-core machine, why doesn't the CPU automatically move a process to a
Current Process: I have a tar.gz file. (Actually, I have about 2000 of them,
I process a lot of text/data that I exchange between Python, R, and sometimes
How to automatically close process that uses more that specified amount of memory on

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.