delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/03/02/16:50:23

X-Recipient: archive-cygwin AT delorie DOT 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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; q=dns; s=default; b=uAs7jE
rCLy+c78AkDWc2luUafhP1W8UAm2nn2KaPBPDZUAou97hSN+zyHld0Lcz8Q4f9j3
OYJbTvxt3O2KEM+6IZG8q+lAXvqtNa3IaxcWG7qzSoBV5acCPnzIOIy39aXeuY2L
E+HmovlfPNQQs8DcajWpTWtQziEeA57WZTqko=
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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; s=default; bh=Vc0at0Ro82nG
eKg4n6hPAeK0vSo=; b=VxLQyDthzWxnEVAzGfFa009q9dte52w0d5tK2uP41ESQ
G319zs0QkmHqbldrnNxKkoIFjnvs7UY1wx+X3nbxUvULZSaHPlzqCifmeNuY1pdu
fnONuvuhObLvbvdi8nbQ2rd3vCoHjf95KISkAHyaFHsN/yeaSTlHrjrMoIFta3g=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-ee0-f41.google.com
X-Received: by 10.14.9.134 with SMTP id 6mr34995921eet.70.1393797004128; Sun, 02 Mar 2014 13:50:04 -0800 (PST)
Message-ID: <5313A789.2080205@gmail.com>
Date: Sun, 02 Mar 2014 22:50:01 +0100
From: =?ISO-8859-1?Q?V=E1clav_Zeman?= <vhaisman AT gmail DOT com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: va_list and char* are ambiguous
References: <CAJoYywUaRcCx4sQ0j_HZZ77urmPjg19fPP=KuM1d8i8Ec3mmWQ AT mail DOT gmail DOT com> <CAJoYywWOHqh9qpFg3skt9XJFVoYgpa0C=g+g6mtEATiArLbgLg AT mail DOT gmail DOT com>
In-Reply-To: <CAJoYywWOHqh9qpFg3skt9XJFVoYgpa0C=g+g6mtEATiArLbgLg@mail.gmail.com>
X-IsSubscribed: yes

--KkW3gRO6m4XpCl9s8xaus6Vc5Lqu8T4Ic
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 03/02/2014 10:45 PM, Irfan Adilovic wrote:
> On Sun, Mar 2, 2014 at 6:58 PM, Irfan Adilovic wrote:
>> irfan AT 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 AT irfy:~$ make x
>> g++     x.cc   -o x
>> irfan AT 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
>=20
> I forgot to mention that calling `foo ("");` will produce:
>=20
> x.cc:7:12: warning: deprecated conversion from string constant to
> 'char*' [-Wwrite-strings]
>      foo ("");
>             ^
>=20
> at compile time and will end up calling va_list at runtime.
I suspect this is due to compatibility with MS compiler on 32 bit
windows, where va_list is also char*.

Does it fail for AMD64 as well? I suspect it should not and it should
work. IIRC the AMD64 MS compiler uses different definition than the 32
bit one. (I cannot check right now.)

I do not think there is much that can be done about it. You will simply
have to rename one of the functions.

--=20
VZ



--KkW3gRO6m4XpCl9s8xaus6Vc5Lqu8T4Ic
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iF4EAREKAAYFAlMTp4kACgkQE3+v/RpUDYDcgAD/ftrKso8pEk1rIIM5zNVUjOdr
8bYK5i++bEu71S4k4lAA/2FQjISA2yWyzX/cv0FXpgNhjFjCAIplHB3yhb7MjA+U
=Pyqc
-----END PGP SIGNATURE-----

--KkW3gRO6m4XpCl9s8xaus6Vc5Lqu8T4Ic--

- Raw text -


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