From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id E0CF43858D28 for ; Fri, 22 Dec 2023 22:03:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E0CF43858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E0CF43858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1031 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703282635; cv=none; b=uFeV3hVJdQISHprPzkofQ3VgLG4ssw3QfQ6me4hAYhvdStcI01Z9ZK7u7t10Gr/TrdPMS3D11p9Q6eL1gxi8kGGZvO8aYTXx31zKnZ8SBPxN+rKDCgZffej54VyWlejBdfxb8gllHTxxPiOVCD82h2m3ESKb34YmGkv6JM3ar0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703282635; c=relaxed/simple; bh=CAdIQ4Wu+cyBBoZyj4Yo0hxUzpuYPqs4lSOBFWK7U/U=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Tl8KEw7x4oOHIlK0bjTmE/bQ5qYNwU5FdElRV0W7HjKSml5L04rrM4a2+SVOLB80Beh/hLT3vmGlRzyt7iVaGxCvuoTq0aEIjSw1mV8uPLQJjZ61httQn5tkZJjRyiGspAcNY5FbIXPRsYMpEPEamhKYYHiSgdd9z+4E70R9W38= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-28659348677so1626535a91.0 for ; Fri, 22 Dec 2023 14:03:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703282633; x=1703887433; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4KV6SrPHXpR/4zO720FVI11obGVfzc05h3sjC2Aed40=; b=X0FGn9hCBZTMQ/lwEwhPboX40PUOID8KBmNko7MqMOWa3COykFzpLTcOcx7sBnmJzV 7fKJrfs2/6vJiHloq4/OWQCMTUdxS+Kek+C1keV6XTwC3R4WrODweXqxhknwk9dPdUpN unu7KC2EtqwF13auy11k0z5V6R+cndzW1/mupzATO6W4bIj6+Id6r8wG3L6ikXrWnU8k idcTl2g+bhETMEEn11mFsVYtUwmgHJuiEgrQNEYIyPvxbLMulPlA+mkFA98k2Zwu1akN +8naXAHTWhBQ1xP9+oGHDyQ0kpXO3ZJW5K7dJ93JMt3chmvFZpiUCBu+zIbChFXSMIRv r3zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703282633; x=1703887433; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4KV6SrPHXpR/4zO720FVI11obGVfzc05h3sjC2Aed40=; b=BQE78XGx6UuehaFWrRV8oRAT0pRfsBERDjqL/3jGjhMFZTyLDMdIdb+c3wmHzcXmbT cyqn7WfgdfOXNgG3qHNgkazBBmxgplvB9bSwZ9bIvOqhRK7j48bGrcmmqwjqIefmKPpv AF15v7quPLBGSI+IQvw6yf5GRiY7/fP8DIkJSuOnW14id+I7a2Gp8JvFtv0xjglnvDrb dszIf5j3IkuYWA6TujDZUQHIw+ii/eCFfJ+RMvSkUZGOd6Co89z8irz0Rmojkwj7EOrB fCuUWMBhVURcqvN4VhTfQAZCfGSTWz6RVb2/eYpz1CdqpZehSWWzAhKBYXSiU5gE7h4x T34Q== X-Gm-Message-State: AOJu0Yy5phLXMxVyG7Tr/Eb8CvCFNS2veaCtbicxPdSE8nMEr/1use64 Y/ruX07tT5zHR5s/NDkfSbhMhZmNDktux7xfiYE= X-Google-Smtp-Source: AGHT+IFfTzXUZmA5bHOcgxz0BP/mG10hVFSFk9rD+5EwaS13Y7GOMUp1PEyXRZHhSpA14kQUa5pq8fPuSCthMhaXq6s= X-Received: by 2002:a17:90b:f07:b0:28c:2678:928e with SMTP id br7-20020a17090b0f0700b0028c2678928emr472404pjb.25.1703282632600; Fri, 22 Dec 2023 14:03:52 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Andrew Pinski Date: Fri, 22 Dec 2023 14:03:41 -0800 Message-ID: Subject: Re: int8_t lives matter To: Olavi Esker Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, Dec 22, 2023 at 1:54=E2=80=AFPM Olavi Esker via Gcc wrote: > > Hello, > > #include > #include > > int main() > { > std::int8_t myInt{65}; > myInt +=3D 1; > std::cout << myInt; > } > > Guess what this returns? > Character "B". > > int main() > { > std::int8_t myInt{}; > std::cin >> myInt; > std::cout << myInt; > } > This will also read a character, and > print the characters ascii value. > So if I give it 3, it read it as '3', and prints out 51. > > > The compiler gives no warning of this whatsoever with the flags: > "-std=3Dc++20", > "-pedantic-errors", > "-Wall", > "-Wpedantic", > "-Wshadow", > "-Wcast-align", > "-Wlogical-op", > "-Wno-unused-parameter", > "-Weffc++", > "-Wextra", > "-Wconversion", > "-Wsign-conversion". > > > t does seem like a mistake to have `signed char` and `unsigned char` > display as characters rather than numbers, since `char` is a distinct typ= e. > And so `char` could display as a character and the other two as integers. > > Wish you can change this. First this is the wrong email list, it should be sent to gcc-help@. Second, your subject line can be read as being offensive to some folks due to the use of the phrase "lives matter". Third, this is what the C++ standard says it should be. And it might be better to be brought up to a C++ forum rather than one about the GCC implementation of the C++ standard. Thanks, Andrew Pinski > > Thanks. > OE