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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:53:14+00:00 2026-05-11T20:53:14+00:00

In GCC, certain warnings require optimization to be enabled. For example: int foo() {

  • 0

In GCC, certain warnings require optimization to be enabled. For example:

int foo() {
    int x;
    return x;
}

In order to detect the uninitialized variable, -O must be passed.

$ gcc -W -Wall -c test.c
$ gcc -W -Wall -c test.c -O
test.c: In function ‘foo’:
test.c:3: warning: ‘x’ is used uninitialized in this function

However, this can interfere with debugging. Is there a way to enable just the analysis phases needed for warnings (and not just this particular warning, but as many as possible), without affecting the generated code too much?

I’m using GCC version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) on x86-64.

  • 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-11T20:53:14+00:00Added an answer on May 11, 2026 at 8:53 pm

    Try using -Wall instead of -W. -W is deprecated IIRC. (As Jonathan Leffler points out in a comment, -W‘s replacement is -Wextra, not -Wall.)

    -Wunused-variable
    Warn whenever a local variable or non-constant static variable is unused aside from its declaration. This warning is enabled by -Wall.

    3.8 Options to Request or Suppress Warnings

    This behavior has changed in GCC 4.4:

    Uninitialized warnings do not require enabling optimization anymore, that is, -Wuninitialized can be used together with -O0. Nonetheless, the warnings given by -Wuninitialized will probably be more accurate if optimization is enabled.

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

Sidebar

Related Questions

What is the best/neatest way to suppress a C compiler (for example GCC) like
I want to sort vector of certain struct with certain order in certain class.
Can ghc somehow be convinced to treat certain types of warnings as errors and
I found that different compiler optimization levels in gcc give quite different results when
GCC has a very verbose format for certain template error messages: ... some_class<A,B,C> [with
Is there a way to ensure the order of static object initialization for certain
GCC is a very well respected multi-language compiler (from what I've gathered). One thing
gcc I am just getting back into c programming and I am just practicing
GCC's recent support for atomic operations (as described here ) is great, and is
gcc 4.4.2 c89 I have a wave file: 8000 Hz 16 bit I am

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.