From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id 603D43858C98 for ; Sat, 23 Dec 2023 00:14:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 603D43858C98 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 603D43858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703290479; cv=none; b=W+LJhkbLfxyPD6NJ+/T7Bmaokexyq5tRq1jmzmKfdIBCDE8D9skvm1Wp9o/Ra4U6UErjdljjRiBlY3cGw/uTIYqZKm5aHqnJCRCTA0UnVf9vBBUSa+qLvTZYyasqlFkCZMUd8BuYC7MRtsj1EaGPjC/3OE26JFNAtuGY+kh2XqM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703290479; c=relaxed/simple; bh=wj1Edh6PcLNzB+1X63vh/HiPKYxwYBiPUDSymmPW/CM=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=K+nEPQDPkuD6vzGYWYVrEK0RDJdSUhd3tjCQ8vjYA39SmFJUfTiqCOpEzBOge8NNTHbm3bSLHN/RvCCSw3drVFvOUyFdShQDvwo3DwCNMSTponOX1qNWOoq0YnqEYEZgKPtHqYOyGWGuHhcPOwp3e78Sp/JnQsoV/rjUjhMf7W0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2cc843af59fso28227081fa.0 for ; Fri, 22 Dec 2023 16:14:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703290476; x=1703895276; darn=gcc.gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=hPZbLb/kOwgFvEUk9dBevojXVOcnMlIgBfFrHFeir6k=; b=KVAXir3CIUFa2ekD0zqatFheEfKDp5yBPCoNC9t2AMW3p0tz8pL/DCoOBKSUAOYAKa agVknFONMxmXDLK1MNQ8VFOJneyfAFXp3Ku0gUQguEuvJLDGCAPzr1e3xAH3M6q5n+3V 0iYy/jaDoSoSa4w4HM8yTIsRd9qCp5ePX4bNo03XD3ZM5GOBs5Z8cIpwdfDubbj8/KOE KcK0gkK6JDnj1jAbY05IBMRp8wCaV+HHI9rRa7Udu3yPKZIIyzOYD6emqZEehWE3PdDA Xn5+JMC/NNe3gZPXcTHSBDQiaZRiqljz3LO6PjLhBWLmQF7+abhfMjg36oDmcIVuzwM7 qhag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703290476; x=1703895276; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=hPZbLb/kOwgFvEUk9dBevojXVOcnMlIgBfFrHFeir6k=; b=v0KuX+h6bPLO6imyUm7XpglVbvx90+MsibEiS8ZTuCzqm9/9/Gb/d+5fNjwNhADZ0X P17AlICR6Y2eQu6IECeSTG0WRfsy7M0ZMjF3MRynNOz8BM4Z+3CWVntncO24h9fj8uXi +u3bRtaCjzd6A8DuvV1Wu7BlT5ifHT23XYUG8kT3oDWFcsjZA4DhMxRYDER6MDSigJGP ITYf+33FjtUJywNA+W//XobO3RuC49G3Nt6kalyReUiwPhL0fXse4GvOTDeiNkh3JNHs OuFEvI/3FiRF7hzUS5vINB4sJf9P3cJdD7E6u+YIJiMg6ESQb2PO0LzsCIcGqE5rBQMx 7d0w== X-Gm-Message-State: AOJu0YxSjQfoTPU69Y98uplfuo3HNS5HmnC0+x4L83jJjnMEO3oyaHFh W2mt1gt7sAH8uxgyZH/jEpVul6aPpOixqalcgOhAJDH+cP0= X-Google-Smtp-Source: AGHT+IHekh9J5IMEAwOKKdSSZxzEN1Hj2hd4Ly09L+6CTFWotWkkT4gFkZCQYox1z+YQ77ND/FdNhIKGIVn+Y2pjfjM= X-Received: by 2002:a2e:9e51:0:b0:2cc:a61c:16f8 with SMTP id g17-20020a2e9e51000000b002cca61c16f8mr934393ljk.46.1703290475583; Fri, 22 Dec 2023 16:14:35 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a05:6022:254:b0:4c:103f:f5b5 with HTTP; Fri, 22 Dec 2023 16:14:35 -0800 (PST) From: Olavi Esker Date: Sat, 23 Dec 2023 02:14:35 +0200 Message-ID: Subject: int8_t outputs char via To: gcc-help@gcc.gnu.org Content-Type: multipart/alternative; boundary="000000000000bf1ccc060d223769" X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,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: --000000000000bf1ccc060d223769 Content-Type: text/plain; charset="UTF-8" Hello, With int8_t prints out char according to ascii number. Similarly it reads a single char, which cannot be static converted. The compiler gives no warning whatsoever. But when is used with scanf %hhd and printf %d it works perfectly. Is this really the intended functioning? In Rust i8 and C int8 works fine, too. #include #include int main() { std::int8_t myInt{65}; myInt += 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=c++20", "-pedantic-errors", "-Wall", "-Wpedantic", "-Wshadow", "-Wcast-align", "-Wlogical-op", "-Wno-unused-parameter", "-Weffc++", "-Wextra", "-Wconversion", "-Wsign-conversion". It does seem like a mistake to have `signed char` and `unsigned char` display as characters rather than numbers, since `char` is a distinct type. And so `char` could display as a character and the other two as integers. Wish you can change this, or at least have a warning, because functions fine for higher bitted integers. Thanks. OE --000000000000bf1ccc060d223769--