public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Ken Brown <kbrown@cornell.edu>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Cc: Denis Vnoukov <imagine@rambler.ru>
Subject: Re: Combo GCC issues with bugs
Date: Sat, 03 Aug 2019 18:59:00 -0000	[thread overview]
Message-ID: <c6466ad8-5ecf-f726-c1ef-235053df4a4d@cornell.edu> (raw)
In-Reply-To: <1564779921.24964.28908.35526@mail.rambler.ru>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3961 bytes --]

On 8/2/2019 5:05 PM, Denis Vnoukov wrote:
> 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

The Linux man page for gcvt says, "Marked as LEGACY in POSIX.1-2001. 
POSIX.1-2008 removes the specification of gcvt(), recommending the use of 
sprintf(3) instead (though snprintf(3) may be preferable)."

Cygwin's stdlib.h is consistent with this.  It guards the declaration of gcvt with

   #if __XSI_VISIBLE >= 4 && __POSIX_VISIBLE < 200112

If you really need to use gcvt, I think you probably have to #define 
_XOPEN_SOURCE to be 500.  (I haven't tested this.)

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

This is a consequence of the fact that gcvt hasn't been declared.

I haven't looked at the rest of the warnings/errors in your message, but I 
suspect you can figure out the causes yourself by looking at the relevant 
headers and/or by looking at the result of preprocessing.  You might also find 
the following helpful:

   https://cygwin.com/faq.html#faq.programming.64bitporting

Ken
\0ТÒÐÐ¥\a&ö&ÆVÒ\a&W\x06÷'G3¢\x02\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒ÷\a&ö&ÆV×2æ‡FÖÀФd\x15\x13¢\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒöf\x17\x12ðФFö7VÖVçF\x17F–öã¢\x02\x02\x02\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒöFö72æ‡FÖÀÐ¥Vç7V'67&–&R\x06–æfó¢\x02\x02\x02\x02\x02\x06‡GG\x03¢òö7–wv–âæ6öÒöÖÂò7Vç7V'67&–&R×6–×\x06ÆPРÐ

  reply	other threads:[~2019-08-03 18:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02 21:05 Denis Vnoukov
2019-08-03 18:59 ` Ken Brown [this message]
     [not found] <1564865987.561926.25803.36864@mail.rambler.ru>
2019-08-03 21:02 ` Denis Vnoukov
2019-08-04 15:00   ` Ken Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c6466ad8-5ecf-f726-c1ef-235053df4a4d@cornell.edu \
    --to=kbrown@cornell.edu \
    --cc=cygwin@cygwin.com \
    --cc=imagine@rambler.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).