public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "stinkingmadgod at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/104179] New: Truncated representation of character arrays as non-type template parameters
Date: Sat, 22 Jan 2022 05:51:09 +0000	[thread overview]
Message-ID: <bug-104179-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 104179
           Summary: Truncated representation of character arrays as
                    non-type template parameters
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stinkingmadgod at gmail dot com
  Target Milestone: ---

#include<algorithm>

template<unsigned N>
struct str
{
    char data[N];
    consteval str(const char (&arr)[N])
    {
        std::copy(arr, arr + N, data);
    }
};

template<str>
struct print;

constexpr char s[] = {'4', '2'};
print<s> p;

Produces the error message

<source>:17:10: error: aggregate 'print<str<2>{"4"}> p' has incomplete type and
cannot be defined
   17 | print<s> p;

Where print<str<2>{"4"}> should be print<str<2>{"42"}>
The intention is likely to print null-terminated strings correctly, as in

print<"42"> p2;

<source>:16:13: error: aggregate 'print<str<3>{"42"}> p2' has incomplete type
and cannot be defined
   16 | print<"42"> p2;

             reply	other threads:[~2022-01-22  5:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-22  5:51 stinkingmadgod at gmail dot com [this message]
2022-01-22 20:34 ` [Bug c++/104179] " pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104179-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).