https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115768

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to biggs from comment #5)
> So the argument here is that C23's constexpr does not permit this
> optimization because it does not allow constexpr pointers other than nullptr?

No I am saying the following is the same C++ testcase where constexpr decl is
not optimized away:
```

#include <stdio.h>

enum ColorEnum {
    CE_RED,
    CE_GREEN,
    CE_BLUE,
};

static constexpr char names[][6] = {
    "RED",
    "GREEN",
    "BLUE",
};

typedef struct Color Color;

struct Color {
    enum ColorEnum value;
};

[[maybe_unused]] static constexpr Color RED = { CE_RED };
[[maybe_unused]] static constexpr Color GREEN = { CE_GREEN };
[[maybe_unused]] static constexpr Color BLUE = { CE_BLUE };

int main() {
    puts(names[RED.value]);
}
```

Say we compare pointers in puts to "RED", if we remove the decl that would be
an invalid transformation since "RED" between two TU might have the same value
(or not) but names[0] and "RED" has to have different addresses.

Reply via email to