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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:03:27+00:00 2026-05-22T22:03:27+00:00

Is this code (simplified from a real project) correct? Will the message always print?

  • 0

Is this code (simplified from a real project) correct? Will the message always print?

char *cp = NULL;
char **cpp = &cp;
if(*cpp == NULL) {
    printf("I believe this will this always print. Does it?\n");
}

Thanks!

  • 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-22T22:03:27+00:00Added an answer on May 22, 2026 at 10:03 pm

    Yes, it will always print.

    You can safely assume that your base stack pointer never points to 0x0, so &cp will always not equal NULL.

    In fact the compiler will eliminate the check at compile time, because it knows &cp != NULL.

    See for yourself:

    Compiled with -O1:

    $ objdump -dC a.out 
    a.out:     file format elf64-x86-64
      ...
    00000000004004f4 <main>:
      4004f4:       48 83 ec 08             sub    $0x8,%rsp
      4004f8:       bf 00 06 40 00          mov    $0x400600,%edi
      4004fd:       e8 ee fe ff ff          callq  4003f0 <puts@plt>
      400502:       b8 00 00 00 00          mov    $0x0,%eax
      400507:       48 83 c4 08             add    $0x8,%rsp
      40050b:       c3                      retq
    

    (With -O0 there will be a test, though:)

    00000000004004f4 <main>:
      4004f4:       55                      push   %rbp
      4004f5:       48 89 e5                mov    %rsp,%rbp
      4004f8:       48 83 ec 10             sub    $0x10,%rsp
      4004fc:       48 c7 45 f0 00 00 00    movq   $0x0,-0x10(%rbp)
      400503:       00 
      400504:       48 8d 45 f0             lea    -0x10(%rbp),%rax
      400508:       48 89 45 f8             mov    %rax,-0x8(%rbp)
      40050c:       48 8b 45 f8             mov    -0x8(%rbp),%rax
      400510:       48 8b 00                mov    (%rax),%rax
      400513:       48 85 c0                test   %rax,%rax
      400516:       75 0a                   jne    400522 <main+0x2e>
      400518:       bf 20 06 40 00          mov    $0x400620,%edi
      40051d:       e8 ce fe ff ff          callq  4003f0 <puts@plt>
      400522:       b8 00 00 00 00          mov    $0x0,%eax
      400527:       c9                      leaveq 
      400528:       c3                      retq
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code (which is way simplified from the real code): public interface
When using this code (simplified for asking): var rows1 = (from t1 in db.TABLE1
is this good code? can it be simplified somehow? SELECT u.id,u.title,u.title,u.first,u.last FROM (((tblusers u
I am reading On lisp and encountered this code (I simplified it a bit).
In a code review, I stumbled over this (simplified) code fragment to unregister an
I have code like this (simplified): def outer(): ctr = 0 def inner(): ctr
This question is partly about delegates, and partly about generics. Given the simplified code:
This is a simplified partial version of my code to demonstrate the issue: function
This is a (very) simplified version of my iPhone code : @interface x {
This is the simplified style for a blog hosted at wordpress.com. The code is

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.