X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:mime-version:in-reply-to:references:date
	:message-id:subject:from:to:content-type; q=dns; s=default; b=IT
	47pSqfXl6M+sfjhwYQ1t+Bl4ZLEwCRZVSVftn2IckI8E58rQB4DsOcJD3shBBNZy
	ClkaM7LtENCQ9M5X1XSW03qwyfosTPbxOc+NYce+a2gGlYnjG7ZDArd+qRSGvzsG
	3E4vauuw/3Rrt0pndMZ95fxVFA/tJUi4TbWjr+MoM=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:mime-version:in-reply-to:references:date
	:message-id:subject:from:to:content-type; s=default; bh=ktKl/AFB
	SrIFt9YZuL+mCxRWkus=; b=l3PwcSwhF8F5EGXIwVoQEa9RPXZHDa2j5q+jvqag
	vO0nAOGbvCyDr1YLcid0ldSkMqCKl20KbV+Piv1SEXWPZxEHmsSLnZXAcaPhAJor
	BGVcmjgw3G1zq9MzRlxtS5opFmzoOt6hAIEzM0tjwwQN4+dCcqXDOil3SUYfVaMV
	W+s=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-ob0-f175.google.com
MIME-Version: 1.0
X-Received: by 10.182.40.201 with SMTP id z9mr3406314obk.45.1393796703282; Sun, 02 Mar 2014 13:45:03 -0800 (PST)
In-Reply-To: <CAJoYywUaRcCx4sQ0j_HZZ77urmPjg19fPP=KuM1d8i8Ec3mmWQ@mail.gmail.com>
References: <CAJoYywUaRcCx4sQ0j_HZZ77urmPjg19fPP=KuM1d8i8Ec3mmWQ@mail.gmail.com>
Date: Sun, 2 Mar 2014 22:45:03 +0100
Message-ID: <CAJoYywWOHqh9qpFg3skt9XJFVoYgpa0C=g+g6mtEATiArLbgLg@mail.gmail.com>
Subject: Re: va_list and char* are ambiguous
From: Irfan Adilovic <irfanadilovic@gmail.com>
To: cygwin@cygwin.com
Content-Type: text/plain; charset=ISO-8859-1
X-IsSubscribed: yes

On Sun, Mar 2, 2014 at 6:58 PM, Irfan Adilovic wrote:
> irfan@irfy:~$ cat x.cc
> #include <cstdarg>
> #include <iostream>
> using namespace std;
> void foo (...)        { cout << "varargs\n"; }
> void foo (va_list ap) { cout << "va_list\n"; }
> int main () {
>     foo ((const char *)NULL);
>     foo ((char *)NULL);
> }
> irfan@irfy:~$ make x
> g++     x.cc   -o x
> irfan@irfy:~$ ./x
> varargs
> va_list
> $ uname -a
> CYGWIN_NT-6.2 irfy 1.7.29(0.271/5/3) 2014-02-21 23:45 x86_64 Cygwin
>
> I would expect the varargs version of foo to be called both times --
> and it does on my linux machine -- but I get the above output under
> Cygwin. It looks like va_list is defined in terms of char*.
>
> Can anyone confirm this behavior on their Cygwin installations?
>
> Is this behavior legal? (in terms of whatever standards apply)
>
> Is there a way to "fix" this? (i.e. typedef va_list as a pointer to a
> struct defined just for the purpose of defining the va_list type)
>
> -- Irfan

I forgot to mention that calling `foo ("");` will produce:

x.cc:7:12: warning: deprecated conversion from string constant to
'char*' [-Wwrite-strings]
     foo ("");
            ^

at compile time and will end up calling va_list at runtime.

-- Irfan

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

