Skip to content

Stack variable and printf cause crash #10

@JonasOberhauser

Description

@JonasOberhauser
#include <assert.h>
#include <stdio.h>

#define LEN 4

int main()
{ 
    int i = 6;
    printf("%d",i); // works
    char str[LEN] = {'%', 'd', 0};
    printf("%s",str); // crash
    printf(str, i); // would also crash
}

The crash also occurs without the initializer (using some other way to set up str).
The crash does not occur if str is changed to static storage duration (I've tried both using the static keyword and moving it outside the function).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions