public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: charles@kde.org To: gcc-gnats@gcc.gnu.org Subject: c++/8176: C++ const**, doesn't implictly cast Date: Wed, 09 Oct 2002 12:06:00 -0000 [thread overview] Message-ID: <20021009190502.8361.qmail@sources.redhat.com> (raw) >Number: 8176 >Category: c++ >Synopsis: C++ const**, doesn't implictly cast >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Wed Oct 09 12:06:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: charles@kde.org >Release: gcc 2.96 through gcc 3.2, probably 2.95 too >Organization: >Environment: Linux >Description: class Bleh { }; void foo(const Bleh **) { } int main(int, char **) { Bleh *bleh; foo(&bleh); // broken Bleh **bar; foo(bar); // broken foo(const_cast<const Bleh**>(bar)); // works const Bleh **works; foo(works); // works } This should work, as <Bleh**> can be casted to <const Bleh**> implicitly Error: bug.cpp: In function `int main (int, char **)': bug.cpp:13: `bleh' undeclared (first use this function) bug.cpp:13: (Each undeclared identifier is reported only once for each function it appears in.) bug.cpp:16: cannot convert `Bleh **' to `const Bleh **' for argument `1' to `foo (const Bleh **)' >How-To-Repeat: Put the compiler in a situation in which it should cast a pointer to a pointer to an object to a pointer to a pointer to a const object (Type** -> const Type**) >Fix: Create a more generic code thing to always implicitly cast a something to a const something. >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-10-09 19:06 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-10-09 12:06 charles [this message] 2002-10-09 12:46 Andreas Schwab 2002-10-09 13:06 Charles Samuels 2002-10-09 13:31 nathan
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=20021009190502.8361.qmail@sources.redhat.com \ --to=charles@kde.org \ --cc=gcc-gnats@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: linkBe 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).