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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:24:01+00:00 2026-06-16T05:24:01+00:00

Before anyone may mark it duplicate of related questions. I emphasize I DO have

  • 0

Before anyone may mark it duplicate of related questions. I emphasize I DO have read all those questions. But I still have some interrogations(yep, some little pedantic 🙂 )

For C

Some conclusions:

1. In C89(C90), this is _undefined_ .
2. In C99(or C11), a type of int is madatory; control flow reached the closing } 
   will return a value of 0. 

Here comes my interrogations.

  1. In c89, I have found nothing about undefined, but unspecified?

    Detail: The related parts in C89 are 5.1.2.2.1 Program startup and 5.1.2.2.3 Program termination (NOTE : both are under the 5.1.2.2 Hosted environment section, within which our later discussion is limitted)

    Cite: — 5.1.2.2.3 Program termination —

    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 If the }
    that terminates the main function is reached, the
    termination status returned to the host environment is
    unspecified.

    Just note that part: If the } that terminates … , it clearly says
    that if we omit the return type – thus the } will be reached at –
    the termination status is unspecified

    According the definition of the standard of undefined and unspecified,
    Should I say that it gives unspecified value since whatever it return is a
    legal int value, but the consequese is undefined-we could not predict what value
    will lead to what catastrophic consequese?

  2. In c99, a type of int is madatory, but gcc --std=c99 given a test without int type(no return type actually) gives only waring:return type of ‘main’ is not ‘int’ ,but not error ?

    Detail: the related parts are the same as that in c89.

    Cite: — 5.1.2.2.1 Program startup —

    It shall be defined with a return type of int and ...

    and — 4. Conformance —

    1. In this International Standard, ‘‘shall’’ is to be interpreted as a requirement on an implementation or on a program; conversely, ‘‘shall not’’ is to be interpreted as a
    prohibition.

    So shall should be interpreted as madatory in this standard, why gcc with swith –std=c99 violated this?

  • 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-16T05:24:02+00:00Added an answer on June 16, 2026 at 5:24 am

    C89/90 still has the implicit int rule, so main() is equivalent to int main(). By leaving off the return type, you’ve implicitly defined the return type as int. Some may consider this sloppy, but it’s strictly conforming (i.e., involves no implementation defined, undefined or unspecified behavior).

    For C99, the implicit int rule has been removed, so main() isn’t defined. However, a compiler is only required to “issue a diagnostic” upon encountering a violation of a Shall or Shall not clause — it’s still free to continue compiling after issuing the diagnostic. Exactly what constitutes a diagnostic is implementation defined. As such, all that’s needed for gcc to conform in this respect is documentation to say that the warning it issues is to be considered a diagnostic.

    Edit: “implicit int” in the C89/90 standard isn’t really a single rule in a single place — it’s spread around in a couple of places. The primary one is §6.5.2.1, where it says:

    — int, signed, signed int, or no type specifiers

    This is part of a list, where all the items on each line of the list are considered equivalent, so this is saying that (unless otherwise prohibited) lack of a type specifier is equivalent to specifying (signed) int.

    For function parameters, there’s a separate specification (at §6.7.1) that: “Any parameter that is not declared has type int.”

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

Sidebar

Related Questions

(Before anyone says anything Yes this was homework but i have already turned it
I've never used Dreamweaver before, but I have some HTML that I am looking
Ok, before anyone attempts to label this as a duplicate, I am not asking
I have a question, which may be a pipe-dream, but I wanted to know
I wonder if anyone has come across this issue before. I have a string
I have begun work on a personal project that may end up having some
I hope no-one has asked this before (I couldn't find anything, but that may
This may have been asked multiple times, but is there a good HTML-to-PDF creator
My eclipse setup for web project worked before. But all of the sudden it
I think this may be a duplicate question. But couldn't find the answer for

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.