• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: malloc was optimized out
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: malloc was optimized out


  • Subject: Re: malloc was optimized out
  • From: Clark Cox <email@hidden>
  • Date: Mon, 04 Jul 2016 15:26:46 -0700



> On Jul 4, 2016, at 13:58, Dmitry Markman <email@hidden> wrote:
>
> Hi Clark, FYI
>
> http://www.dii.uchile.cl/~daespino/files/Iso_C_1999_definition.pdf

I am *well* aware of what the standard says.

>
> 7.20.3.3 The malloc function
> . . . . .
> Description
> 2 The malloc function allocates space for an object
> whose size is specified by size and whose value is indeterminate.
> Returns
> 3 The malloc function returns either a null pointer
> or a pointer to the allocated space.
>
> so there is nothing in C standard about never returning NULL

Also note that there is nothing in the standard about *requiring* that NULL be returned. On a modern, UNIX system malloc will typically “succeed” and return a pointer to a not-yet-paged in block of memory. As far as the C standard is concerned, that malloc succeeded in allocating a block of memory. However, when you later go and access that memory, and the OS realizes that it can’t handle the resulting page-fault, your program crashes. This is a long-time, and well understood issue; and in light of that behavior, the compiler is 100% correct to do what it is doing.

>> On Jul 4, 2016, at 3:58 PM, Clark Cox <email@hidden> wrote:
>>
>> Malloc effectively *never* returns NULL.

Notice the word “effectively”.

--
Clark Smith Cox III
email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: malloc was optimized out
      • From: Dmitry Markman <email@hidden>
References: 
 >malloc was optimized out (From: Dmitry Markman <email@hidden>)
 >Re: malloc was optimized out (From: Clark Cox <email@hidden>)
 >Re: malloc was optimized out (From: Dmitry Markman <email@hidden>)

  • Prev by Date: trying to get C++ code using NEON intrinsics to build
  • Next by Date: Re: trying to get C++ code using NEON intrinsics to build
  • Previous by thread: Re: malloc was optimized out
  • Next by thread: Re: malloc was optimized out
  • Index(es):
    • Date
    • Thread