Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<xstring>: constexpr string does not compile with -d1initall #4473

Closed
tiagomacarios opened this issue Mar 12, 2024 · 7 comments · Fixed by #4474
Closed

<xstring>: constexpr string does not compile with -d1initall #4473

tiagomacarios opened this issue Mar 12, 2024 · 7 comments · Fixed by #4474
Labels
bug Something isn't working fixed Something works now, yay!

Comments

@tiagomacarios
Copy link
Member

The following code stopped compiling when d1initall is enabled.
https://godbolt.org/z/9EW3z1s5P

#include <string>

constexpr bool f() noexcept {
    std::string gate_name{"aaaaaaaaaaaaaaaaaaaaaa"};
    return true;
}

constexpr bool b = f();

Godbolt shows the regression starting in v19.38. Cameron helped me track the regression to PR 490538: Port 14 GitHub PRs: GH-3939, GH-3900, GH-3935, GH-3912, GH-3927, GH-3936, GH-3862, GH-3903, GH-3904, GH-3920, GH-3921, GH-3930, GH-3933, GH-3934.

@AlexGuteniev
Copy link
Contributor

Suspect this is GH-3862 , and in particular this uninitialized pointer:

STL/stl/inc/xstring

Lines 2618 to 2624 in d6efe94

pointer _Fancy_ptr;
if constexpr (_Policy == _Allocation_policy::_At_least) {
_Fancy_ptr = _Allocate_at_least_helper(_Al, _Capacity);
} else {
_STL_INTERNAL_STATIC_ASSERT(_Policy == _Allocation_policy::_Exactly);
_Fancy_ptr = _Al.allocate(_Capacity);
}

The -d1initall1023 -d1initAll:FillPatternE switches don't like that

@tiagomacarios
Copy link
Member Author

Your suggested fix works.
We are currently using 19.38.33135 which ICEs with the fix. The last released version 19.39.33522 works correctly.

tiagomacarios added a commit to tiagomacarios/STL that referenced this issue Mar 13, 2024
@CaseyCarter CaseyCarter added the bug Something isn't working label Mar 13, 2024
@CaseyCarter
Copy link
Contributor

The following code stopped compiling when d1initall is enabled. https://godbolt.org/z/9EW3z1s5P

Well, I suppose it's a good thing that option isn't documented, or we'd have a bug! =P

@AlexGuteniev
Copy link
Contributor

It looks like that it is a bug in these options, I'd expect delay initialized pointer to compile

@frederick-vs-ja
Copy link
Contributor

Reduced example (Godbolt link)

constexpr bool fun()
{
    char* p [[maybe_unused]];
    return true;
}

constexpr bool b = fun();

Filed DevCom-10614520.

@StephanTLavavej StephanTLavavej added the fixed Something works now, yay! label Mar 16, 2024
@AlexGuteniev
Copy link
Contributor

DevCom-10614520 is Fixed - pending release.

Should we keep the initialization or pull it out later?

@tiagomacarios
Copy link
Member Author

Just keep it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants