From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16449 invoked by alias); 7 Feb 2018 15:19:18 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 16426 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-f178.google.com Received: from mail-io0-f178.google.com (HELO mail-io0-f178.google.com) (209.85.223.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Feb 2018 15:19:16 +0000 Received: by mail-io0-f178.google.com with SMTP id f4so2349650ioh.8 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=F0NfO0tDaEl1VJ/1CyYj1LYELowblmnBGGa+69HvghVyQ85VSuZub3ww6eJXj39QZQ 9f2ED56mNUecnOLTq/FvUOOWzYO3vGqTdCz1ZUFlXy+BeZc8Xtl8EXzA52rAwwmt8RYJ MzigPv6P/vKy9ddHhWIzVO5FCZJFkw+VnjcS1UEHsw+L8bbCF83Zw8qPzZSyQjX+kD00 4ERPKUeGabTW7NbVU7fOLoJYtHlrfuXLE2/ZuzzgJdg19c4qgDPaFs3Z1NoK5uHAG7gT POg5xW86FOKolPQVas04yKeSwDIxo4z6E5kWCSBOLaNcEP8WEFb2LdBdt0EPaSBGaZS3 s7kQ== X-Gm-Message-State: APf1xPCHPt++urCHO8a9Esq68qwHvenPXTwspv3CsvNFyAeZ5qGLy/KF u4aeC+Zndz44NuQylkG8tFWzkHYMA2wVTeUaBYo= 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-SW-Source: 2018-02/txt/msg00058.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