Hello There, Guest!
View New Posts  |  View Today's Posts
MinGw Bug (Compound Literals C99)

  • 0 Vote(s) - 0 Average


12-29-2016, 08:16 PM #1
AceInfinity
Developer
*******
Administrators
Posts: 9,726 Threads:1,023 Joined: Jun 2011 Reputation: 76

MinGw Bug (Compound Literals C99)
I noticed some unexpected behavior when using compound literals in C under MinGw, but also Microsoft's compiler (which wasn't too surprising since they kind of half-fully support C99, and focus more on C++ support).

http://ideone.com/HLn9Hb

^ This code compiled under a non-port of gcc (strict C99) will yield the proper time result string.

Other tests on my MinGw compiler result in a pointer that is not null, but asctime() returns a NULL string and therefore nothing is really output to stdout.

Code:
puts(asctime(&(const struct tm) { .tm_hour = 1, .tm_min = 2, .tm_sec = 3}));

I tried assigning the address to a pointer from outside of the function call, with the same bad result. The scope shouldn't end until the function returns really, so a dangling pointer is not the issue here. Compiles and executes fine with the expected result in clang (tested 3.7).

My own MinGw version: gcc (i686-posix-dwarf-rev0, Built by MinGW-W64 project) 5.4.0

Tested on bash on Windows with gcc installed, and the correct string was output to stdout. (gcc (Ubuntu 4.9.4-2ubuntu1~14.04.1) 4.9.4)

Filed a bug report to see what people say.

Same command line from makefile for both compilers (gcc on bash, gcc on Windows (MinGw))
Code:
gcc -std=c99 -Wall -Wextra -pedantic -fstrict-aliasing -O2 main.c -static-libgcc  -o main
This post was last modified: 12-29-2016, 08:24 PM by AceInfinity.


Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer

Development Site: aceinfinity.net

 ▲
 ▲ ▲

01-07-2017, 02:31 PM #2
AceInfinity
Developer
*******
Administrators
Posts: 9,726 Threads:1,023 Joined: Jun 2011 Reputation: 76

RE: MinGw Bug (Compound Literals C99)
Still doesn't work in build: gcc (i686-posix-dwarf-rev1, Built by MinGW-W64 project) 6.2.0

My submitted bug report has no traction currently, no updates on the ticket. Best bet is to stick with a compiler like clang since I'm sure that should work. :)


Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer

Development Site: aceinfinity.net

 ▲
 ▲ ▲




Forum Jump:



Users browsing this thread: 1 Guest(s)