Thanks to visit codestin.com
Credit goes to github.com

Skip to content

32-bit-only misoptimization of printf calls on Windows #62762

@CaseyCarter

Description

@CaseyCarter

This program:

#include <stdio.h>
#include <stdlib.h>

int main() {
    for (int i = 0; i < 32; ++i) {
        printf("%u ", rand());
    }
    printf("\n");
}

prints 32 copies of the same integer value when compiled with optimization in an x86 Visual Studio 2022 17.7 Preview 1 command prompt (clang -O1 repro.c -o repro.exe). Note that this is the first VS preview to include Clang 16, specifically LLVM-16.0.1. Clang 15.0.1 included in the box with VS 2022 17.6 correctly compiles the program with and without optimization targeting either x64 or x86.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions