[comp.sys.mac.programmer] Think C 4.01 bugs

blm@6sceng.UUCP (Brian Matthews) (07/17/90)

In article <25571@cs.yale.edu> tarr-michael@CS.YALE.EDU (michael tarr) writes:
|char s1[10];
|char s2[20] = "A long string";
|strncpy(s1, s2, 8);
|
|s1 will not have a '\0' appended to the end. So far as I can tell this
|is not per the standard definition.

Yes it is.  s1 should only have a 0 appended if s2 is shorter than 8
characters.  It's not, so no 0 should be appended.  This is how strncpy
has been defined since the beginning of time (1970 or so :-)).

|Also sizeof returns an int, but malloc and calloc require size_t! This
|is hidden on a none highlighted single line of text... Caused me great
|pain to find this...

If Think C 4.01 claims to be ANSI conformant, this is definitely a bug.
-- 
Brian L. Matthews	blm@6sceng.UUCP

bhil@ohs.UUCP (Brian T. Hill) (07/19/90)

From article <455@6sceng.UUCP>, by blm@6sceng.UUCP (Brian Matthews):
> In article <25571@cs.yale.edu> tarr-michael@CS.YALE.EDU (michael tarr) writes:
> |Also sizeof returns an int, but malloc and calloc require size_t! This
> |is hidden on a none highlighted single line of text... Caused me great
> |pain to find this...
> 
> If Think C 4.01 claims to be ANSI conformant, this is definitely a bug.
> -- 
> Brian L. Matthews	blm@6sceng.UUCP

In the THINK C User's manual, page 440, section 7.4.8 of the Language
reference, it says:
  "In THINK C, the type that sizeof returns is int, not size_t."
The reason for this, IMHO, is to allow you to say:
  "NewHandle(sizeof(int))"
where NewHandle() expects an int.

Furthermore, on page 442, section 12.10, it says:
  "The identifier __STDC__ is not defined in THINK C.  They symbol THINK_C is
  defined as 1 in THINK C."
It says on page 10:
  "Many new language features in this release make THINK C more compatible
  with the ANSI C standard.  Although THINK C is close to the standard, it
  is not conformant as defined in the standard.  The remaining issues either
  are of little significance or would require fundamental changes to THINK C.
  For more information on ANSI compatibility, read the [Language reference]
  Chapter 57."

Brian T. Hill		bhil@ohs.UUCP  (bhil@ohs.uunet)
trACE(tm) Software Development
175 South  400 East
Orem, Utah, 84058
(801) 227-8778

julian@riacs.edu (Julian E Gomez) (07/23/90)

In article <570@ohs.UUCP> bhil@ohs.UUCP (Brian T. Hill) writes:
" From article <455@6sceng.UUCP>, by blm@6sceng.UUCP (Brian Matthews):
" 
" In the THINK C User's manual, page 440, section 7.4.8 of the Language
" reference, it says:
"   "In THINK C, the type that sizeof returns is int, not size_t."
" The reason for this, IMHO, is to allow you to say:
"   "NewHandle(sizeof(int))"
" where NewHandle() expects an int.
No go. NewHandle takes a long. See pages II-32 and II-46.

"   "Many new language features in this release make THINK C more compatible
"   with the ANSI C standard.  Although THINK C is close to the standard, it
"   is not conformant as defined in the standard.  The remaining issues either
"   are of little significance or would require fundamental changes to THINK C.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
In Symantec's opinion.
-- 

"We must grasp the bull by the tail, and look the matter squarely in the face!"

	Julian "a tribble took it" Gomez     julian@riacs.edu