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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:55:31+00:00 2026-05-15T19:55:31+00:00

I stumbled across something interesting and I cant put my finger why the behaviour

  • 0

I stumbled across something “interesting” and I cant put my finger why the behaviour isn’t coherent.

Check this code.

char buf[100];
sprint(buf,"%s",bla);

Simple, right. It’s easy to understand what is going on when bla is a NULL pointer.

This should always segfault right!?

In one machine the executable segfaults, on another (my development machine), it’s just business as usual.

My devel PC is running Windows7 and I’m compiling with gcc/MingW. The computer where this is crashing is XP and it does have Visual studio 6 installed.

Why doesn’t this crash on my PC?

  • 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-15T19:55:31+00:00Added an answer on May 15, 2026 at 7:55 pm

    ISO C99: 7.19.6.3 The printf function

    Synopsis

     #include <stdio.h>
     int printf(const char * restrict format, ...);
    

    The printf function is equivalent to fprintf with the argument stdout interposed before the arguments to printf.

    7.19.6.1 The fprintf function

    7.19.6.1.9

    If a conversion specification is invalid, the behavior is **undefined**. If any argument is
    not the correct type for the corresponding conversion specification, the behavior is **undefined**.

    So your code invokes Undefined Behavior [(ISO C99 3.4.3)
    behavior, upon use of a nonportable or erroneous program construct or of erroneous data,
    for which this International Standard imposes **no requirements**
    ]

    This should always segfault right!?

    Not necessarily, Undefined Behavior means anything can happen.

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

Sidebar

Related Questions

I stumbled across this code and am too proud to go and ask the
I stumbled across this C code today. Can anyone tell me what the 'where'
I just stumbled across this bug in some legacy code: class MyAPIHandler { private:
Searching something on SO, I stumbled across this question and one of the comments
I stumbled across this article and found it very interesting, so I ran some
I stumbled across this problem in F#. Suppose, I want to declare two types
I recently stumbled across this entry in the google testing blog about guidelines for
I've stumbled across this great post about validating parameters in C#, and now I
I stumbled across something I can't figure out myself. I have an android project
I am working my way through learning Twisted, and have stumbled across something I'm

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.