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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:18:21+00:00 2026-05-14T00:18:21+00:00

I’ve found what I think may be a bug with Ivar and Objective-C runtime.

  • 0

I’ve found what I think may be a bug with Ivar and Objective-C runtime. I’m using XCode 3.2.1 and associated libraries, developing a 64 bit app on X86_64 (MacBook Pro).

Where I would expect the type encoding for the following “longVal” to be ‘l’, the Ivar encoding is showing a ‘q’ (which is a ‘long long’).

Anyone else seeing this? Simplified code and output follows:

Code:

#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface Bug : NSObject
{
    long        longVal;
    long long   longerVal;
}
@property (nonatomic,assign) long longVal;
@property (nonatomic,assign) long long longerVal;
@end

@implementation Bug

@synthesize longVal,longerVal;

@end


int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    unsigned int    ivarCount=0;
    Ivar *ivars= class_copyIvarList([Bug class], &ivarCount);

    for(unsigned int x=0;x<ivarCount;x++) {
        NSLog(@"Name [%@] encoding [%@]",
         [NSString stringWithCString:ivar_getName(ivars[x]) encoding:NSUTF8StringEncoding],
              [NSString stringWithCString:ivar_getTypeEncoding(ivars[x]) encoding:NSUTF8StringEncoding]);
    }

    [pool drain];
    return 0;
}

And here is output from debug console:

This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000
Loading program into debugger…
sharedlibrary apply-load-rules all
Program loaded.
run
[Switching to process 6048]
Running…
2010-03-17 22:16:29.138 ivarbug[6048:a0f] Name [longVal] encoding [q]
2010-03-17 22:16:29.146 ivarbug[6048:a0f] Name [longerVal] encoding [q]
(gdb) continue

Not a pretty picture!

— Frank

  • 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-14T00:18:21+00:00Added an answer on May 14, 2026 at 12:18 am

    It’s not a bug. The GCC compiler, under a 64 bits architecture, chooses to represent longs as 64 bit integers. You can check it yourself:

    printf("%lu\n", sizeof(long)); // will give "8"
    

    As a reminder, the C standard only defines minimum sizes for integer types. long is only guaranteed to be at least 32 bits.

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

Sidebar

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.