delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/09/16/12:53:30

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-developers-unsubscribe-archive-cygwin-developers=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Subscribe: <mailto:cygwin-developers-subscribe AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-developers-help AT sourceware DOT cygnus DOT com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
Date: Thu, 16 Sep 1999 12:55:19 -0400
From: Chris Faylor <cgf AT cygnus DOT com>
To: Mumit Khan <khan AT xraylith DOT wisc DOT EDU>
Cc: cygwin-developers AT sourceware DOT cygnus DOT com
Subject: Re: (patch) makethread stdcall/cdecl confusion
Message-ID: <19990916125519.D655@cygnus.com>
Mail-Followup-To: Mumit Khan <khan AT xraylith DOT wisc DOT EDU>,
cygwin-developers AT sourceware DOT cygnus DOT com
References: <19990916122311 DOT A655 AT cygnus DOT com> <199909161529 DOT KAA06946 AT mercury DOT xraylith DOT wisc DOT edu>
Mime-Version: 1.0
X-Mailer: Mutt 0.95.6i
In-Reply-To: <199909161529.KAA06946@mercury.xraylith.wisc.edu>; from Mumit Khan on Thu, Sep 16, 1999 at 10:29:50AM -0500

On Thu, Sep 16, 1999 at 10:29:50AM -0500, Mumit Khan wrote:
>Another issue when you're dealing with thread start routines -- it's 
>almost always better to malloc the the parameter argument instead of
>passing the address of a stack data element. It'll work in the current
>usages in winsup, but this usage can lead to very subtle and hard to
>track errors. 

That's probably because, AFAICT, in every case where the argument is
non-NULL it *is* malloced.

>> The other question is why didn't the compiler catch this problem?
>
>The C++ front-end has trouble catching these. Try the following:
>
>  #include <windows.h>
>
>  extern int foo (LPTHREAD_START_ROUTINE);
>  static DWORD bar (void *) { return 0; }
>  static DWORD WINAPI bar2 (void *) { return 0; }
>
>  int
>  main ()
>  {
>    foo (bar);
>    foo (bar2);
>    return 0;
>  }
>
>And you'll see why I resist using anything but the cdecl calling 
>convention in my code. The C front-end does do the right thing.

Yes.  It's obviously broken.  The winsup code proves that.

cgf

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019