Skip to content

strcmp() with short string literal not folded away #58003

@firewave

Description

@firewave
#include <cstring>

bool f(const char* c)
{
    return strcmp(c, "0") == 0;
}

https://godbolt.org/z/soThM1sre

GCC folds away the strcmp() for strings up to two characters. I also tried using __builtin_strcmp() and -fno-builtin but that didn't make any difference. But to be honest I am not familiar with the builtin stuff at all.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions