public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/92181] initializer_list & string_view result in "modification of '<temporary>' is not a constant expression
       [not found] <bug-92181-4@http.gcc.gnu.org/bugzilla/>
@ 2020-07-14 12:42 ` hyena at hyena dot net.ee
  2020-07-14 13:39 ` hyena at hyena dot net.ee
  2023-06-30 14:11 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: hyena at hyena dot net.ee @ 2020-07-14 12:42 UTC (permalink / raw)
  To: gcc-bugs

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

Erich Erstu <hyena at hyena dot net.ee> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hyena at hyena dot net.ee

--- Comment #3 from Erich Erstu <hyena at hyena dot net.ee> ---
I started getting the same error after upgrading to GCC 9.3.0.

The problem in my case is either related to the use of std::pair in constexpr
or the fact that I have nested instances of std::initializer_list.

The workaround was to replace std::pair with a custom struct as seen here:

struct zone_name_root_variant_type {
    const char *name;
    std::initializer_list<ZONE_NAME_AFFIX> affixes;
};

struct zone_name_root_type {
    ZONE_NAME_ROOT index;
    const char *region;
    std::initializer_list<
        zone_name_root_variant_type
        /*
        std::pair<
            const char*,
            std::initializer_list<ZONE_NAME_AFFIX>
        >
        */
    > variants;
};

static constexpr const zone_name_root_type zone_name_root_table[] = {
    {
        ZONE_NAME_ROOT::UNKNOWN, "Region",
        {
            {  "",     { ZONE_NAME_AFFIX::UNKNOWN } }
        }
    },
    { ZONE_NAME_ROOT::NONE, "", { } }
};

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/92181] initializer_list & string_view result in "modification of '<temporary>' is not a constant expression
       [not found] <bug-92181-4@http.gcc.gnu.org/bugzilla/>
  2020-07-14 12:42 ` [Bug c++/92181] initializer_list & string_view result in "modification of '<temporary>' is not a constant expression hyena at hyena dot net.ee
@ 2020-07-14 13:39 ` hyena at hyena dot net.ee
  2023-06-30 14:11 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: hyena at hyena dot net.ee @ 2020-07-14 13:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Erich Erstu <hyena at hyena dot net.ee> ---
I also found out that when I try to populate a constexpr array using a trivial
constexpr function that passes on the argument initializer list then I get the
same error.

This does not work any more within the definition of a constexpr array:

constexpr room_desc_part_type make(
    ROOM_DESC_PART part, std::initializer_list<const char *> args
) {
    return
#if __cplusplus <= 201703L
    __extension__
#endif // __cplusplus
    room_desc_part_type{
        .index = part,
        .arguments = args
    };
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/92181] initializer_list & string_view result in "modification of '<temporary>' is not a constant expression
       [not found] <bug-92181-4@http.gcc.gnu.org/bugzilla/>
  2020-07-14 12:42 ` [Bug c++/92181] initializer_list & string_view result in "modification of '<temporary>' is not a constant expression hyena at hyena dot net.ee
  2020-07-14 13:39 ` hyena at hyena dot net.ee
@ 2023-06-30 14:11 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-06-30 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |12.3
         Depends on|                            |107079
         Resolution|---                         |FIXED

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Looks like this is fixed for GCC 12.3+ by the fix for PR107079.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107079
[Bug 107079] [10/11 Regression] ICE initializing lifetime-extended constexpr
variable that stores its this pointer

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-30 14:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-92181-4@http.gcc.gnu.org/bugzilla/>
2020-07-14 12:42 ` [Bug c++/92181] initializer_list & string_view result in "modification of '<temporary>' is not a constant expression hyena at hyena dot net.ee
2020-07-14 13:39 ` hyena at hyena dot net.ee
2023-06-30 14:11 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).