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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:57:07+00:00 2026-06-05T16:57:07+00:00

I am trying to avoid C6011 warning because an abort function is calling exit().

  • 0

I am trying to avoid C6011 warning because an abort function is calling exit(). How can I do that?

Here is an example:

#include <stdlib.h>

void abort_function();
void func( int *p );

int main()
{
    int x;

    func( &x );

    return 0;
}

void func( int *p )
{
    if (NULL == p)
        abort_function();

    *p = 5;
}

void abort_function()
{
    exit(0);
}

So this leads to the following warning from PREFast:

warning C6011: Dereferencing NULL pointer 'p': Lines: 17, 18, 20

Simply replacing abort_function() with exit(0) eliminates this warning.

But I’m actually working with a large codebase, and I didn’t want to replace all calls to abort_function(). So I was able to eliminate a lot of these warnings by making the function a variadic macro, and temporarily taking out the function definition, like this:

#include <stdlib.h>

#define abort_function( ... ) exit(0);

/*void abort_function();*/
void func( int *p );

int main()
{
    int x;

    func( &x );

    return 0;
}

void func( int *p )
{
    if (NULL == p)
        abort_function();

    *p = 5;
}

#if 0
void abort_function()
{
    exit(0);
}
#endif

This also eliminated the warning, but are there any PREFast options or annotations I could use, to avoid having to modify the code?

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

    In MSVC, defining __declspec(noreturn) for abort_function should do it.
    For gcc, __attribute__ ((noreturn)) does the same.

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

Sidebar

Related Questions

I'm trying to avoid an app crash here... I have a button that will
I'm trying to avoid reinventing the wheel here. I'm looking for a GEM that
Trying to avoid the SomethingManager trap here... Let's say I'm going to write a
I'm trying to avoid the use of magic strings as much as I can,
I'm trying to avoid this: function do_something($arg1, $arg2, $arg3, $arg4, $arg5) { function do_something_else($arg1,
I'm trying to avoid the use of eval . I can dynamically instantiate a
I am trying to avoid LOKI_TYPELIST_n macros, so I though I can write simple
Trying to avoid repetition here. I have an action in a base class controller
From the get go, let me say that I'm trying to avoid using pcntl_fork()
I've been trying to avoid using a cursor in this particular case just because

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.