delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/08/02/17:06:15

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:from:to:reply-to:subject:date:message-id
:mime-version:content-type:content-transfer-encoding; q=dns; s=
default; b=GAiWxpAF+7f2HErUGdSplMmBrRTnyH4OSNkSSzrYZEl3UOZK4kEV+
RPCyNtcKk9Zf1MQYjozjcHYfi080Fp4msIYUoztLREX13CAVK/Xtr+aRpcQatuIm
lqYdEhxz5unFdj8S1I+ltVpwM2BBYZw3OkkC0eAI8Gy40K556/qkFc=
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:from:to:reply-to:subject:date:message-id
:mime-version:content-type:content-transfer-encoding; s=default;
bh=1VNFSYab81/BrKgfbA8jxIKIcL4=; b=OOls+Zor8Zs6YALkLuyGXf9+VWUh
W+xhIGSV/z9UHoOOjpLuPAQh+plVxfiWa/3evqo51+5BKdcfOnOuqzqDopl03XUD
9aZvOhVKVlJ0/7PYyOOpwRruS4MByhw6WN+gwEgV5mhaxgN77eWCiUbg6RL24ZbP
miv+V78ZYu4Z2ng=
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-Spam-SWARE-Status: No, score=-5.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,KAM_LOTSOFHASH,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.1 spammy=H*R:D*rambler.ru, UD:But, UD:htm, man-pages
X-HELO: mxout2.rambler.ru
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rambler.ru; s=mail; t=1564779921; bh=vbgHNS6P1yuzYqzP2aarTy5Vr6qEhUv+HIhYCJ1uSBM=; h=From:To:Reply-To:Subject:Date; b=eCmSMg5WHHH+PYQc0Pk9TN2Qtisd+vDTymY7Bvyu0UwgRU1wNGeYOJ4hv7QjyyNAb c83oFCHuzpwpKftvNMYljt61kl766OkQdQvljdtFZM3dZEYgSqUhJyoXYxC+MGecs3 eJ3+qP9G3pZQaZh7kuKr9Ljvis1pXV7xftOeWm2U=
From: "Denis Vnoukov" <imagine AT rambler DOT ru>
To: "cygwin" <cygwin AT cygwin DOT com>
Reply-To: "Denis Vnoukov" <imagine AT rambler DOT ru>
Subject: Combo GCC issues with bugs
Date: Sat, 3 Aug 2019 00:05:21 +0300
Message-Id: <1564779921.24964.28908.35526@mail.rambler.ru>
MIME-Version: 1.0
X-Rambler-User: imagine AT rambler DOT ru/5.228.238.131
X-IsSubscribed: yes
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id x72L5uAR021409

Code Example:
#include <stdlib.h>
#include <stdio.h>
#include <sys/select.h>
#include <windows.h>
#include <stdint.h>
#include <intrin.h>int main()
{
// https://github.com/msys2/MSYS2-packages/issues/1711
char buf[50];
char * str = gcvt(3.141592653589793238462643383279502884197169399375, 49, buf);
printf("buffer: %s", str);// https://github.com/msys2/MSYS2-packages/issues/1270
fd_set read_fd;
FD_ZERO(&read_fd);GetTickCount64();//
https://github.com/msys2/MSYS2-packages/issues/1262
unsigned long index;
uint64_t b = 0xbedabedadeadc0de;
_BitScanForward64(&index, b);
_BitScanReverse64(&index, b);return 0;
}
If we compile it with gcc as .c:
$ gcc main.c
main.c: In function ‘main’:
main.c:16:15: warning: implicit declaration of function ‘gcvt’
[-Wimplicit-function-declaration]
char * str = gcvt(3.141592653589793238462643383279502884197169399375, 49, buf);
^~~~
main.c:16:15: warning: initialization makes pointer from integer without a cast
[-Wint-conversion]
main.c:23:2: warning: implicit declaration of function ‘GetTickCount64’; did you
mean ‘GetTickCount’? [-Wimplicit-function-declaration]
GetTickCount64();
^~~~~~~~~~~~~~
GetTickCount
main.c:28:20: warning: passing argument 1 of ‘_BitScanForward64’ from
incompatible pointer type [-Wincompatible-pointer-types]
_BitScanForward64(&index, b);
^
In file included from /usr/include/w32api/winnt.h:27:0,
from /usr/include/w32api/minwindef.h:163,
from /usr/include/w32api/windef.h:8,
from /usr/include/w32api/windows.h:69,
from main.c:8:
/usr/include/w32api/psdk_inc/intrin-impl.h:749:1: note: expected ‘unsigned int *’
but argument is of type ‘long unsigned int *’
__buildbitscan(_BitScanForward64, unsigned __int64, "bsf{q %[Mask],%[Index] |
%[Index],%[Mask]}")
^
main.c:29:20: warning: passing argument 1 of ‘_BitScanReverse64’ from
incompatible pointer type [-Wincompatible-pointer-types]
_BitScanReverse64(&index, b);
^
In file included from /usr/include/w32api/winnt.h:27:0,
from /usr/include/w32api/minwindef.h:163,
from /usr/include/w32api/windef.h:8,
from /usr/include/w32api/windows.h:69,
from main.c:8:
/usr/include/w32api/psdk_inc/intrin-impl.h:756:1: note: expected ‘unsigned int *’
but argument is of type ‘long unsigned int *’
__buildbitscan(_BitScanReverse64, unsigned __int64, "bsr{q %[Mask],%[Index] |
%[Index],%[Mask]}")
^
So...
1. gcvt function must be into stdlib.h, but we have a warning
2. gcvt function in all standards has declaration like:char *gcvt(double number,
int ndigit, char *buf);but we have a warning about "int-conversion" and get core
dump on line:printf("buffer: %s", str);
3. We have a warning about "implicit declaration of function" GetTickCount64();But
it can be available with windows.hhttps://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount64
4. We have a warning about "incompatible pointer type" for _BitScanForward64 and
_BitScanReverse64 functions.But declaration from Microsoft looks like:unsigned
char _BitScanForward64( unsigned long * Index, unsigned __int64 Mask );https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64?view=vs-2019
Then, let's compile source via g++ with -Wold-style-cast option as .cpp:
$ g++ -Wold-style-cast main.cpp
main.cpp: In function ‘int main()’:
main.cpp:16:15: error: ‘gcvt’ was not declared in this scope
char * str = gcvt(3.141592653589793238462643383279502884197169399375, 49, buf);
^~~~
In file included from /usr/include/sys/types.h:52:0,
from /usr/include/stdio.h:61,
from main.cpp:6:
main.cpp:21:11: warning: use of old-style cast [-Wold-style-cast]
FD_ZERO(&read_fd);
^
main.cpp:23:2: error: ‘GetTickCount64’ was not declared in this scope
GetTickCount64();
^~~~~~~~~~~~~~
main.cpp:23:2: note: suggested alternative: ‘GetTickCount’
GetTickCount64();
^~~~~~~~~~~~~~
GetTickCount
main.cpp:28:29: error: cannot convert ‘long unsigned int*’ to ‘unsigned int*’ for
argument ‘1’ to ‘unsigned char _BitScanForward64(unsigned int*, long long
unsigned int)’
_BitScanForward64(&index, b);
^
main.cpp:29:29: error: cannot convert ‘long unsigned int*’ to ‘unsigned int*’ for
argument ‘1’ to ‘unsigned char _BitScanReverse64(unsigned int*, long long
unsigned int)’
_BitScanReverse64(&index, b);

So...1. error: ‘gcvt’ was not declared in this scopebut it must be into stdlib.h
as well:MSVC:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/gcvt?view=vs-2019
Linux man: http://man7.org/linux/man-pages/man3/gcvt.3.html
And from IBM:
https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.bpxbd00/rgcvt.htm
2.main.cpp:21:11: warning: use of old-style cast [-Wold-style-cast]
FD_ZERO(&read_fd);This is bullshit.
3. error: ‘GetTickCount64’ was not declared in this scopeSee Above.
4. For BitScanForward64/_BitScanReverse64 - error: cannot convert ‘long unsigned
int*’ to ‘unsigned int*’ for argument ‘1’See Above.

--
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


- Raw text -


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