Skip to content

strlen calls on non-const char[] not folded #42969

@nickdesaulniers

Description

@nickdesaulniers
Bugzilla Link 43624
Version trunk
OS Linux
CC @davidbolvansky,@DougGregor,@zygoloid,@stephenhines

Extended Description

#include <stdio.h>
#include <string.h>
void f(const char *s){
char foo [] = "hello\n";
printf("%lu\n", strlen(foo));
foo[0] = '\0';
printf("%lu\n", strlen(foo));
}

https://godbolt.org/z/T1m9UM

Looks like GCC nicely determines the strlen at compile time. Seems nice to have.

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