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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:57:04+00:00 2026-06-12T17:57:04+00:00

From this question , I’ve seen a funny code which compile (although with warnings)

  • 0

From this question, I’ve seen a funny code which compile (although with warnings) and produce a segmentation fault (gcc 4.4.4; clang 2.8):

main;

If we expand it, here is the result:

int main = 0;

So what is the linker’s behavior here?

  • 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-12T17:57:05+00:00Added an answer on June 12, 2026 at 5:57 pm

    The linker’s behavior is that it defines a symbol called main in either the program’s data or BSS segment. It is 4 bytes long and initialized to 0. Ordinarily, it creates a symbol in the program’s code segment (typically called .text) with the executable code for the main function.

    The C runtime starts up at a fixed entry point (typically called _start), initializes a bunch of stuff (e.g. sets up the program’s arguments), and calls the main function. When main is executable code, this is all fine and dandy, but if it’s instead 4 zero bytes, the program will transfer control to those zero bytes and try to execute them.

    Typically, the data and BSS segments are marked as non-executable, so when you try to execute code there, the processor will raise an exception, which the OS will interpret and then terminate your program with a signal. If somehow the segment it’s in is executable, then it will try to execute the machine instructions defined by 00 00 00 00. In x86 and x86-64, that’s an illegal instruction, so you’d also get a SIGILL signal in POSIX OSes.

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

Sidebar

Related Questions

This snippet (taken from this question ) compiles fine with g++ (as seen), so
Following on from this question, I find myself writing the following code over and
From this question I asked 5 minutes ago, it's clear that the following code
From this Question I obtained the great function areaPolygon() which gives me the area
This question is followed up question from 'This question' . The codeigniter code returns
This question stems from this question Code documentation how much is too much? One
Following on from this question I now have code that can attach to a
From this question & the answers - What is the correct answer for cout
From this question I learned Double.NaN is not equal to itself. I was verifying
Continuing from this question : When I am trying to do fopen on Windows,

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.