Skip to content

Parentheses around stdout/stderr definitions cause unqualified-id errors with C++ members named stdout/stderr #6

@paul-reilly

Description

@paul-reilly

I initially came across this when testing the new safe C and C++ compiler, Fil-C:

pizlonator/fil-c#37

But it turns out that the issue can be reproduced using only musl:

#include <string>

struct Foo { std::string stderr = "oooh"; } foo;

int main()
{
    auto stderr = 42;
    foo.stderr = "aaah";
}

Output:

➜  musltest xmake -rv
[ 50%]: cache compiling.release src/main.cpp
/tmp/.xmake1000/250605/zigcc/c++ -c -target x86_64-linux-musl -fvisibility=hidden -fvisibility-inlines-hidden -O3 -Ibuild/.gens/musltest/cross/x86_64/release/platform/windows/idl -DNDEBUG -o build/.objs/musltest/cross/x86_64/release/src/main.cpp.o src/main.cpp
error: src/main.cpp:8:9: error: expected unqualified-id
    8 |     foo.stderr = "aaah";
      |         ^
/home/dev/.xmake/packages/z/zig/0.14.0/f5e2b0c8c8b74e00a0ff2ba18c896a4c/lib/libc/include/generic-musl/stdio.h:68:16: note: expanded from macro 'stderr'
   68 | #define stderr (stderr)
      |                ^
1 error generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions