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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:06:43+00:00 2026-06-13T00:06:43+00:00

I have some C programs without any explicit return from main, like this: int

  • 0

I have some C programs without any explicit return from main, like this:

int main(int argc, char *argv[])
{
  // blah blah
}

If I compile them with GCC 4.6.3 and the following options:

gcc file.c -Wall -Wextra

Programs does not return 0 and give me problems, but the standard (and a lot of other answers on SO) says:

If the return type of the main function is a type compatible with int, a return from the initial call to the main function is equivalent to calling the exit function with the value returned by the main function as its argument;[10] reaching the } that terminates the main function returns a value of 0. If the return type is not compatible with int, the termination status returned to the host environment is unspecified.

[10] In accordance with 6.2.4, the lifetimes of objects with automatic storage duration declared in main will have ended in the former case, even where they would not have in the latter.

My programs return different values, 160, 15, 14… garbage?

Am I missing something? Is this a GCC bug? Can’t find anything in the GCC online doc.
Is GCC still referring to some old C standard (pre-C99) where this could be not specified?

  • 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-06-13T00:06:44+00:00Added an answer on June 13, 2026 at 12:06 am

    By default gcc is -std=gnu89 which is C90 + GNU extensions.

    And C90 says:

    (C90, 5.1.2.2.3) “If the main function executes a return that specifies no value, the termination status returned to the host environment is undefined”

    Compiles with -std=c99 or -std=gnu99 to have a return value of 0 when return is omitted in main function.

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

Sidebar

Related Questions

I have been trying some programs in the C Language and come across to
I'm starting to learn about COBOL. I have some experience writing programs that deal
I am debugging some programs. In per-instruction debugging (Eclipse CDT), I have come across
I have several Delphi programs that maintain connections to a database (some Oracle, some
I have a makefile for compiling Arduino programs . I need to add some
I have an Excel spreadsheet that I have exported from some other program. It
guys I want to start programing with C++. I have written some programs in
I have written some smaller rails programs before and am fairly well versed in
I have some code, that I'm currently porting from OS X to Linux (console
I have written a simple SSL Client/Server set of programs from a few tutorials

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.