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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:57:17+00:00 2026-06-04T15:57:17+00:00

I was wondering why does the following code not throw an error during compilation?

  • 0

I was wondering why does the following code not throw an error during compilation? :

#include <stdio.h>
char * func (char *);

int main()
{
    func("TINFO");
    func("INFO");
}

char * func(char * str)
{
    if (str[0] == 'T')
    return str + 1;
}

You see there is a return path from the function that does not return a char *

Similar Java code throws a compile time error, though.

Compiler used:

gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
  • 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-04T15:57:19+00:00Added an answer on June 4, 2026 at 3:57 pm

    According to C standard, 6.9.1.12, reaching an end of the function is undefined behavior only if the caller uses the returned value:

    If the } that terminates a function is reached, and the value of the function call is used by the caller, the behavior is undefined.

    That’s why the compiler must let this code compile.

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

Sidebar

Related Questions

I am wondering why in the following code the static integer does not stay
I am wondering why the following regex does not match. string query = \1
The following code does not compile in gcc: namespace One{ class A{ }; };
.I have the following code. I am wondering why does my echo '<font color=#FF0000>'.$update_date2.'</font><br><br>'.$status.'<br>';
I have the following code when i add to the list it does not
I've seen the following often lately and I'm wondering what it does? I can't
I have the code below. I'm wondering that does the self.value and _value have
Just wondering, would the following code arrangement cause any issues when calling mysql_connect, i.e.:
I was wondering, whether the following code are safe. public class GUIBundle { //
I am trying to figure this out, given the following code, does the Refresh()

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.