executeUpdateWithFormat fails with "EXC_BAD_INSTRUCTION" #15

Closed
guoxj opened this Issue May 3, 2011 · 4 comments

Comments

Projects
None yet
3 participants

guoxj commented May 3, 2011

fmdb.m[line 472] FMDBQuickCheck(([db executeUpdateWithFormat:@"insert into t5 values (%s, %d, %@, %c, %lld)", "text", 42, @"BLOB", 'd', 12345678901234])); fail with EXC_BAD_INSTRUCTION

my env :ios 4 xcode 4.0.2

would please fix it?

Contributor

davedelong commented May 3, 2011

I can't reproduce this when compiling for either 32-bit or 64-bit mode. Can you post a bit more about your setup?

guoxj commented May 3, 2011

i import the content of "src" forder into iphone4 project . and i use xcode 4.0.2 .the compiler is LLVM GCC 4.2.
may be you just compiler for mac app. but i use it for ios develop.
and i have fix this:
in FMDatabase.m

  • (void)_extractSQL:(NSString *)sql argumentsList:(va_list)args intoString:(NSMutableString *)cleanedSQL arguments:(NSMutableArray *)arguments
    change :
    //arg = [NSString stringWithFormat:@"%c", va_arg(args, char)]; break;
    //bugfix:guoxj
    to:
    arg = [NSString stringWithFormat:@"%c", va_arg(args, int)]; break;

i am not a native english speaker.sorry for my english.

guoxj commented May 3, 2011

i compile it in LLVM GCC
It gave me an warning:
char' is promoted toint' when passed through ...' (so you should passint' not char' tova_arg')
note: if this code is reached, the program will abort
then i find:
va_arg(ap,type)
type can not be the types below:
——char、signed char、unsigned char
——short、unsigned short
——signed short、short int、signed short int、unsigned short int
——float

and i benefit from your excellent work. thanks

Contributor

davedelong commented May 3, 2011

aha, clang was not reporting this as an issue. I'll work up a patch and request that gus merge it in.

@ccgus ccgus closed this Jul 14, 2011

ccgus added a commit that referenced this issue Aug 17, 2011

Merge pull request #28 from mpakes/master
Fix for issue #15 - va_arg errors with LLVM GCC 4.2

petersondrew pushed a commit to petersondrew/fmdb that referenced this issue Jan 9, 2012

Merge pull request #28 from mpakes/master
Fix for issue #15 - va_arg errors with LLVM GCC 4.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment