public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65293] New: improve error message on static_casting incomplete types.
@ 2015-03-03  8:03 chengniansun at gmail dot com
  2015-03-03 10:19 ` [Bug c++/65293] " redi at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: chengniansun at gmail dot com @ 2015-03-03  8:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65293
           Summary: improve error message on static_casting incomplete
                    types.
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com

It took me a while to figure out that the cause of the error is the incomplete
definition of destination type. I wonder whether it is possible to improve the
error message by mentioning "incomplete", similar to what Clang does. I believe
doing this will provide more information to developers to fix this type of
errors. 



$: cat t.cc 
class A;
class B;

void f(const B &b) {
  const A &a = static_cast<const A&>(b);
}
$: 
$: 
$: ~/tools/gcc-install/bin/g++ -c t.cc 
t.cc: In function ‘void f(const B&)’:
t.cc:5:39: error: invalid static_cast from type ‘const B’ to type ‘const A&’
   const A &a = static_cast<const A&>(b);
                                       ^
$: 
$: clang++ -c t.cc
t.cc:5:16: error: no viable conversion from 'const B' to incomplete type 'const
A'
  const A &a = static_cast<const A&>(b);
               ^                     ~
t.cc:1:7: note: forward declaration of 'A'
class A;
      ^
1 error generated.
$:
>From gcc-bugs-return-479106-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Mar 03 08:21:15 2015
Return-Path: <gcc-bugs-return-479106-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 30448 invoked by alias); 3 Mar 2015 08:21:15 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 30398 invoked by uid 48); 3 Mar 2015 08:21:11 -0000
From: "maltsevm at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/65289] [5.0 regression] ICE when compiling libjpegturbo with -floop-nest-optimize
Date: Tue, 03 Mar 2015 08:21:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: major
X-Bugzilla-Who: maltsevm at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-65289-4-ehkYY64rsx@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65289-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65289-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-03/txt/msg00250.txt.bz2
Content-length: 2054

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide289

Mikhail Maltsev <maltsevm at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maltsevm at gmail dot com

--- Comment #2 from Mikhail Maltsev <maltsevm at gmail dot com> ---
Reduced test case, reproduces ICE for both sets of options (-O2
-fgraphite-identity and -O2 -floop-nest-optimize):

tjCompress2(srcBuf, height) {
  int i, *row_pointer;
  if (_setjmp())
    for (; i < height; i++)
      row_pointer[i] = srcBuf;
  jpeg_abort_compress();
}

Of course, this program now involves undefined behavior, but the error message
is still the same as in the original one.

Here is another example:

void bar ();
int foo (char *dest, int i)
{
    _setjmp();
    while (i)
        dest[--i] = 0;
    bar();
}

./test1.c: In function 'foo':
./test1.c:2:5: error: loop 2's latch is marked as part of irreducible region
 int foo (char *dest, int i)
     ^
./test1.c:2:5: error: edge from 16 to 19 should be marked irreducible
./test1.c:2:5: error: basic block 19 should be marked irreducible
./test1.c:2:5: error: edge from 19 to 17 should be marked irreducible
./test1.c:2:5: error: basic block 20 should not be marked irreducible
./test1.c:2:5: error: edge from 20 to 25 should not be marked irreducible
./test1.c:2:5: error: basic block 25 should not be marked irreducible
./test1.c:2:5: error: edge from 25 to 23 should not be marked irreducible
./test1.c:2:5: error: basic block 23 should not be marked irreducible
./test1.c:2:5: error: edge from 23 to 24 should be marked irreducible
./test1.c:2:5: error: basic block 21 should not be marked irreducible
./test1.c:2:5: error: edge from 21 to 20 should not be marked irreducible
./test1.c:2:5: error: basic block 24 should be marked irreducible
./test1.c:2:5: error: edge from 24 to 18 should be marked irreducible
./test1.c:2:5: internal compiler error: in verify_loop_structure, at
cfgloop.c:1652


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

* [Bug c++/65293] improve error message on static_casting incomplete types.
  2015-03-03  8:03 [Bug c++/65293] New: improve error message on static_casting incomplete types chengniansun at gmail dot com
@ 2015-03-03 10:19 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2015-03-03 10:19 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Duplicate.

*** This bug has been marked as a duplicate of bug 52321 ***


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

end of thread, other threads:[~2015-03-03 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-03  8:03 [Bug c++/65293] New: improve error message on static_casting incomplete types chengniansun at gmail dot com
2015-03-03 10:19 ` [Bug c++/65293] " redi 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).