From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16450 invoked by alias); 7 Feb 2018 15:19:19 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 16427 invoked by uid 89); 7 Feb 2018 15:19:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1861 X-HELO: mail-io0-f176.google.com Received: from mail-io0-f176.google.com (HELO mail-io0-f176.google.com) (209.85.223.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Feb 2018 15:19:16 +0000 Received: by mail-io0-f176.google.com with SMTP id b198so2362595iof.6 for ; Wed, 07 Feb 2018 07:19:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=BUWN3BCliRHP51uB3zcKuE+X/rNNZ0ViaXrZmBShJ/M=; b=EATU1GIS1Gp8HKejEu38neo70mlPYuJgQobP+8ZA3Q1BUGhy+U5aZ3IfRK/ZiubcRa V9aRp4sqO0PxhQxH0jm+avOCqHVKYtrW60C5da79uOCH8f5rrjnhypvQ/2OH6CbWQnYh 6yqUjhmmjry64iaBHvYITiHaPfivZF/XRjMqsQq5b3T7jT7hgQ0Xg0GKsjjsmopetAJG RuXsm8oQFqJBDz0xfc6t9mnzrkDdN98tzSzhhoIeWT3+VKJCPVBTRr/NCRvQQZXHwmqE 9YmDrME97qZkuHzUavmlxnFpv8aBQVI5EdKBD4hjRcwP43ZNr3Zi+i+3ZPnlfQ9cqlU8 fbWA== X-Gm-Message-State: APf1xPA2Ady1mvKpfq4aAke6crUw6T8/AOaMdRTIgX/qb34s6wy/6j97 e+2uJcYWiK8TWc27E8Ll64urb6JPD/YVGie0Y/k= X-Google-Smtp-Source: AH8x227q0vdKCd12QW61qkbH1odQrpZKjifqzZKQkb1lgjDSAu3uYmZwKvJ9WSIOZ9YXtd4ObHr8Bsfm60ayvgWZrgQ= X-Received: by 10.107.173.225 with SMTP id m94mr7961566ioo.36.1518016754840; Wed, 07 Feb 2018 07:19:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.50.198 with HTTP; Wed, 7 Feb 2018 07:19:14 -0800 (PST) In-Reply-To: <1b58e2df-5425-4f22-510c-d2e9f51040ba@polymtl.ca> References: <1517667601.3405.123.camel@gnu.org> <1b58e2df-5425-4f22-510c-d2e9f51040ba@polymtl.ca> From: Jonathan Wakely Date: Wed, 07 Feb 2018 15:19:00 -0000 Message-ID: Subject: Re: gdb 8.x - g++ 7.x compatibility To: Simon Marchi Cc: Manfred , gdb@sourceware.org, "gcc@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00070.txt.bz2 On 4 February 2018 at 05:01, Simon Marchi wrote: > On 2018-02-03 13:35, Manfred wrote: >> n4659 17.4 (Type equivalence) p1.3: >> >> Two template-ids refer to the same class, function, or variable if >> ... >> their corresponding non-type template arguments of integral or >> enumeration type have identical values >> ... >> >> It looks that for non-type template arguments the template type >> equivalence is based on argument /value/ not /type/ (and value), so >> IMHO gcc is correct where it considers foo<10u> and foo<10> to be the >> same type, i.e. "refer to the same class" >> >> FWIW, type_info reports the same class name for both templates, which >> appears to be correct as per the above. >> >> I would think someone from gcc might be more specific on why both >> templates print 4294967286, and what debug info is actually stored by >> -g in this case. > > I think that Roman's example clearly shows that they are not equivalent in > all cases. > > Building Roman's example with g++ 7.3 results in a single instantiated type. You > can see that both "new foo<10>()" and "new foo<10u>()" end up calling the same > constructor. It seems like which type is instantiated depends on which template > parameter (the signed or unsigned one) you use first. So with this: > > base * fi = new foo<10>(); > base * fu = new foo<10u>(); > > the output is -10 for both, and with > > base * fu = new foo<10u>(); > base * fi = new foo<10>(); > > the output is 4294967286 for both. But it's probably a bogus behavior. I tested > with clangd, it instantiates two different types, so you get 4294967286 for the > <10u> case and -10 for the <10> case. I also just built gcc from master, and it > also instantiates two types, so it seems like that was fixed recently. That was https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79092 FWIW