1. #1
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,708

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

    Ideone.com - HLn9Hb - Online IDE & Debugging Tool

    ^ 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))
    ` gcc -std=c99 -Wall -Wextra -pedantic -fstrict-aliasing -O2 main.c -static-libgcc -o main
    Last edited by AceInfinity; 12-29-2016 at 10:29 PM.
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net


    • Ad Bot

      advertising
      Beep.

        
       

  2. #2
    AceInfinity's Avatar
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,708

    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. :)
    \n\n

    Automation Programmer
    Development Site: aceinfinity.net

Log in

Log in