Pelles C forum

Pelles C => Bug reports => Topic started by: Prokrust on March 23, 2021, 10:43:46 AM

Title: Invalid result of the strnlen_s() function in debug 64-bit mode
Post by: Prokrust on March 23, 2021, 10:43:46 AM

#define __STDC_WANT_LIB_EXT1__  1
#include <stdio.h>
#include <string.h>

unsigned len_func(const char * ss, unsigned size) {
return (unsigned)strnlen_s(ss,size);
}

int main(int argc, char *argv[]) { (void)argv[argc];
printf("strnlen_s = %llu\n", strnlen_s("qwe",6));
printf("len_func = %u\n", len_func("qwe",6));
return 0;
}

Result in Debug 64-bit mode:
Quote
strnlen_s = 3
len_func = 12
Title: Re: Invalid result of the strnlen_s() function in debug 64-bit mode
Post by: John Z on May 03, 2021, 11:28:39 AM
Hi Prokrust,

I'm tried this today and you are right as far as I can tell.  Same code w/o debug produces different results than with using debug mode.

John Z