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

  • Home
  • SEARCH
  • 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 4105750
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:17:16+00:00 2026-05-20T21:17:16+00:00

#include <iostream> int main(int argc, char** args) { int foo = foo + 4;

  • 0
#include <iostream>

int main(int argc, char** args) {
  int foo = foo + 4;
  std::cout << foo << std::endl;
}

And a follow up question, is there a compiler flag to stop this sort of thing? I found -Wall works sometimes, better would be to prevent it entirely.

My compiler:  
g++ -v  
Using built-in specs.  
Target: i486-linux-gnu  
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu  
Thread model: posix  
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)  
  • 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-20T21:17:17+00:00Added an answer on May 20, 2026 at 9:17 pm

    No there is no guaranteed way to stop this sort of thing. It is an integral part of C++ and C that the variable’s name is visible in its initializer. It allows you to do such things as

    T *t = malloc(sizeof(*t));
    

    There is an issue report on the C++ issues list to require diagnostics in simple cases, but currently compilers are not required to diagnose your case.

    It’s also valid in a different context.

    Edit: To clarify – the behavior of your snippet is undefined: You are reading the value of a not initialized variable. That compilers are not required to diagnose this does not mean that behavior is defined.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code #include <iostream> using namespace std; int main(int argc,char **argv) {
i have following code #include <iostream> using namespace std; int main(int argc,char arg[]){ int
#include <cstdlib> #include <iostream> int main(int argc, char *argv[]) { cout << "size of
Just ran into this: #include <iostream> using namespace std; int main(int argc, char** argv)
I created a program called test: #include<stdlib.h> #include<iostream> int main() { std::cout<<system(..\\add\\debug\\add.exe 4 8);
#include <iostream> using namespace std; int main() { double u = 0; double w
#include <iostream> #include <vector> using namespace std; int main() { vector< vector<int> > dp(50000,
I have this program in c++: #include <iostream> using namespace std; int main() {
How can I implement the following in python? #include <iostream> int main() { std::string
#include iostream #include string using namespace std; #define AA(bb) \ string(::##bb); int main (int

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.