Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localtime returns null (LDC 1.13.0-beta1 Win64) #2903

Closed
SimonN opened this issue Nov 7, 2018 · 2 comments
Closed

localtime returns null (LDC 1.13.0-beta1 Win64) #2903

SimonN opened this issue Nov 7, 2018 · 2 comments

Comments

@SimonN
Copy link

SimonN commented Nov 7, 2018

Windows 64-bit version of LDC 1.13.0-beta-1. Here is an example D program:

import core.stdc.time;

void main()
{
    time_t timestamp = time(null);
    tm*    loctime   = localtime(&timestamp);
    assert (loctime !is null, "OK on DMD, NG on LDC Win 64-bit 1.13.0-beta-1");
}

The C standard library's localtime function should return a pointer to a statically allocated non-threadsafe struct. With the returned pointer, we can then access the fields of the struct to get years, months, ...

The assert passes when this example program gets built with on DMD 64-bit on Linux, DMD 32-bit on Windows, LDC 1.12 on Linux.

The assert fails when the example is built with LDC 64-bit 1.13.0-beta1. Expected: The assert passes here, too.

@kinke
Copy link
Member

kinke commented Nov 7, 2018

Thx, that's a bug in the MinGW-w64 .def file, defining localtime as alias for _localtime64 for the 64-bit libs, while it should be _localtime32. There seem to be more related bugs, e.g., gmtime. I'll have a look.

kinke added a commit to kinke/installer that referenced this issue Nov 8, 2018
Ignore the aliases in the MinGW-w64 .def files altogether; they are
not just incomplete, but sometimes also wrong (e.g.,
ldc-developers/ldc#2903; there were more of
these after I checked against msvcrt.lib).

I decided to write a little tool to extract these aliases from the MS
libs. The resulting output for VS 2015 oldnames.lib and msvcrt.lib is
included (as well as the tool) as input files for the generated linker
directives in oldnames.lib.
kinke added a commit to kinke/installer that referenced this issue Nov 8, 2018
Ignore the aliases in the MinGW-w64 .def files altogether; they are
not just incomplete, but sometimes also wrong (e.g.,
ldc-developers/ldc#2903; there were more of
these after I checked against msvcrt.lib).

I decided to write a little tool to extract these aliases from the MS
libs. The resulting output for VS 2015 oldnames.lib and msvcrt.lib is
included (as well as the tool) as input files for the generated linker
directives in oldnames.lib.
@kinke
Copy link
Member

kinke commented Nov 9, 2018

FIxed in master now, along with a few other wrong aliases.

@kinke kinke closed this as completed Nov 9, 2018
wilzbach pushed a commit to kinke/installer that referenced this issue Apr 14, 2019
Ignore the aliases in the MinGW-w64 .def files altogether; they are
not just incomplete, but sometimes also wrong (e.g.,
ldc-developers/ldc#2903; there were more of
these after I checked against msvcrt.lib).

I decided to write a little tool to extract these aliases from the MS
libs. The resulting output for VS 2015 oldnames.lib and msvcrt.lib is
included (as well as the tool) as input files for the generated linker
directives in oldnames.lib.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants