public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "chengniansun at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/67580] New: Improve error message on missing "struct" tag
Date: Mon, 14 Sep 2015 22:41:00 -0000	[thread overview]
Message-ID: <bug-67580-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 67580
           Summary: Improve error message on missing "struct" tag
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com
  Target Milestone: ---

I wonder whether the error message on missing the 'struct' tag can be improved.
IMHO, clang gives a clearer message on how to fix the error. This also applies
to union types.  

$: cat t.c
struct S {int s;};

void f(int a) {
  S s = {a};
}
$: gcc-trunk -c t.c
t.c: In function ‘f’:
t.c:4:3: error: unknown type name ‘S’
   S s = {a};
   ^
$: clang-trunk -c t.c
t.c:4:3: error: must use 'struct' tag to refer to type 'S'
  S s = {a};
  ^
  struct 
1 error generated.
$:
>From gcc-bugs-return-497215-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Sep 15 00:11:25 2015
Return-Path: <gcc-bugs-return-497215-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 100403 invoked by alias); 15 Sep 2015 00:11:25 -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 100320 invoked by uid 48); 15 Sep 2015 00:11:16 -0000
From: "su at cs dot ucdavis.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/67581] New: ICE on transparent union with -g enabled on x86_64-linux-gnu (verify_type failed)
Date: Tue, 15 Sep 2015 00:11:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: su at cs dot ucdavis.edu
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone
Message-ID: <bug-67581-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-09/txt/msg01193.txt.bz2
Content-length: 6337

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

            Bug ID: 67581
           Summary: ICE on transparent union with -g enabled on
                    x86_64-linux-gnu (verify_type failed)
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

The following code causes an ICE when compiled with the current gcc trunk on
x86_64-linux-gnu when -g is enabled.

This is a regression from 5.2.x.


$ g++-trunk -v
Using built-in specs.
COLLECT_GCC=g++-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 6.0.0 20150914 (experimental) [trunk revision 227747] (GCC)
$
$ g++-trunk -c t.cc
$ g++-5.2 -c -g t.cc
$
$ g++-trunk -c -g t.cc
t.cc:1:7: error: type variant differs by TYPE_TRANSPARENT_AGGR.
 union U
       ^
 <union_type 0x7fefaab41348 U asm_written transparent-aggr type_5 SI
    size <integer_cst 0x7fefaa9fd0a8 type <integer_type 0x7fefaa9df2a0
bitsizetype> constant 32>
    unit size <integer_cst 0x7fefaa9fd0c0 type <integer_type 0x7fefaa9df1f8
sizetype> constant 4>
    align 32 symtab -1432334256 alias set -1 canonical type 0x7fefaab41348
    fields <field_decl 0x7fefaab3e4c0 x
        type <integer_type 0x7fefaa9df7e0 int asm_written public SI size
<integer_cst 0x7fefaa9fd0a8 32> unit size <integer_cst 0x7fefaa9fd0c0 4>
            align 32 symtab -1432334096 alias set -1 canonical type
0x7fefaa9df7e0 precision 32 min <integer_cst 0x7fefaa9fd060 -2147483648> max
<integer_cst 0x7fefaa9fd078 2147483647>
            pointer_to_this <pointer_type 0x7fefaaa01930>>
        nonlocal decl_3 SI file t.cc line 3 col 7 size <integer_cst
0x7fefaa9fd0a8 32> unit size <integer_cst 0x7fefaa9fd0c0 4>
        align 32 offset_align 128
        offset <integer_cst 0x7fefaa9dbe88 constant 0>
        bit offset <integer_cst 0x7fefaa9dbed0 constant 0> context <union_type
0x7fefaab41348 U>
        chain <field_decl 0x7fefaab3e558 y type <real_type 0x7fefaaa01540
float>
            nonlocal decl_3 SF file t.cc line 4 col 9 size <integer_cst
0x7fefaa9fd0a8 32> unit size <integer_cst 0x7fefaa9fd0c0 4>
            align 32 offset_align 128 offset <integer_cst 0x7fefaa9dbe88 0> bit
offset <integer_cst 0x7fefaa9dbed0 0> context <union_type 0x7fefaab41348 U>
chain <type_decl 0x7fefaab3e428 U>>> context <translation_unit_decl
0x7fefabdb01e0 D.1>
    full-name "union U"
    X() X(constX&) this=(X&)
    chain <type_decl 0x7fefaab3e390 U>>
 <union_type 0x7fefaab413f0 U type_5 SI
    size <integer_cst 0x7fefaa9fd0a8 type <integer_type 0x7fefaa9df2a0
bitsizetype> constant 32>
    unit size <integer_cst 0x7fefaa9fd0c0 type <integer_type 0x7fefaa9df1f8
sizetype> constant 4>
    align 32 symtab 0 alias set -1 canonical type 0x7fefaab41348
    fields <field_decl 0x7fefaab3e4c0 x
        type <integer_type 0x7fefaa9df7e0 int asm_written public SI size
<integer_cst 0x7fefaa9fd0a8 32> unit size <integer_cst 0x7fefaa9fd0c0 4>
            align 32 symtab -1432334096 alias set -1 canonical type
0x7fefaa9df7e0 precision 32 min <integer_cst 0x7fefaa9fd060 -2147483648> max
<integer_cst 0x7fefaa9fd078 2147483647>
            pointer_to_this <pointer_type 0x7fefaaa01930>>
        nonlocal decl_3 SI file t.cc line 3 col 7 size <integer_cst
0x7fefaa9fd0a8 32> unit size <integer_cst 0x7fefaa9fd0c0 4>
        align 32 offset_align 128
        offset <integer_cst 0x7fefaa9dbe88 constant 0>
        bit offset <integer_cst 0x7fefaa9dbed0 constant 0> context <union_type
0x7fefaab41348 U>
        chain <field_decl 0x7fefaab3e558 y type <real_type 0x7fefaaa01540
float>
            nonlocal decl_3 SF file t.cc line 4 col 9 size <integer_cst
0x7fefaa9fd0a8 32> unit size <integer_cst 0x7fefaa9fd0c0 4>
            align 32 offset_align 128 offset <integer_cst 0x7fefaa9dbe88 0> bit
offset <integer_cst 0x7fefaa9dbed0 0> context <union_type 0x7fefaab41348 U>
chain <type_decl 0x7fefaab3e428 U>>> context <translation_unit_decl
0x7fefabdb01e0 D.1>
    full-name "union U"
    X() X(constX&) this=(X&)
    chain <type_decl 0x7fefaab3e390 U>>
t.cc:1:7: internal compiler error: verify_type failed
0xf1ebf9 verify_type(tree_node const*)
        ../../gcc-trunk/gcc/tree.c:13583
0x97fb04 gen_type_die_with_usage
        ../../gcc-trunk/gcc/dwarf2out.c:20707
0x981186 gen_type_die
        ../../gcc-trunk/gcc/dwarf2out.c:20901
0x98d7c1 gen_decl_die
        ../../gcc-trunk/gcc/dwarf2out.c:21487
0x97ef9d gen_member_die
        ../../gcc-trunk/gcc/dwarf2out.c:20378
0x97ef9d gen_struct_or_union_type_die
        ../../gcc-trunk/gcc/dwarf2out.c:20483
0x97ef9d gen_tagged_type_die
        ../../gcc-trunk/gcc/dwarf2out.c:20684
0x9805ed gen_type_die_with_usage
        ../../gcc-trunk/gcc/dwarf2out.c:20846
0x981186 gen_type_die
        ../../gcc-trunk/gcc/dwarf2out.c:20901
0x98d7c1 gen_decl_die
        ../../gcc-trunk/gcc/dwarf2out.c:21487
0x98e27c dwarf2out_decl
        ../../gcc-trunk/gcc/dwarf2out.c:21937
0x98e5ab dwarf2out_type_decl
        ../../gcc-trunk/gcc/dwarf2out.c:21647
0xbbcbff rest_of_type_compilation(tree_node*, int)
        ../../gcc-trunk/gcc/passes.c:339
0x6a47ac finish_struct_1(tree_node*)
        ../../gcc-trunk/gcc/cp/class.c:6747
0x6a61e4 finish_struct(tree_node*, tree_node*)
        ../../gcc-trunk/gcc/cp/class.c:6913
0x6df81b cp_parser_class_specifier_1
        ../../gcc-trunk/gcc/cp/parser.c:20443
0x6df81b cp_parser_class_specifier
        ../../gcc-trunk/gcc/cp/parser.c:20671
0x6df81b cp_parser_type_specifier
        ../../gcc-trunk/gcc/cp/parser.c:15076
0x6ef4ab cp_parser_decl_specifier_seq
        ../../gcc-trunk/gcc/cp/parser.c:12042
0x703d10 cp_parser_simple_declaration
        ../../gcc-trunk/gcc/cp/parser.c:11608
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$


-------------------------------------------


union U
{
  int x;
  float y;
} __attribute__ ((__transparent_union__));


             reply	other threads:[~2015-09-14 22:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-14 22:41 chengniansun at gmail dot com [this message]
2015-09-15  0:17 ` [Bug c/67580] " manu at gcc dot gnu.org
2015-09-15 17:19 ` mpolacek at gcc dot gnu.org
2015-09-15 17:20 ` mpolacek at gcc dot gnu.org
2015-09-17 23:34 ` manu 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-67580-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).