int8_t lives matter

2023-12-22 Thread Olavi Esker via Gcc
Hello,

#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".


t 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.

Thanks.
OE


Re: int8_t lives matter

2023-12-22 Thread Andrew Pinski via Gcc
On Fri, Dec 22, 2023 at 1:54 PM Olavi Esker via Gcc  wrote:
>
> Hello,
>
> #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".
>
>
> t 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.

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


gcc-12-20231222 is now available

2023-12-22 Thread GCC Administrator via Gcc
Snapshot gcc-12-20231222 is now available on
  https://gcc.gnu.org/pub/gcc/snapshots/12-20231222/
and on various mirrors, see https://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 12 git branch
with the following options: git://gcc.gnu.org/git/gcc.git branch 
releases/gcc-12 revision e60b7838a01926ba247b89e9710fa51d73af7e42

You'll find:

 gcc-12-20231222.tar.xz   Complete GCC

  SHA256=3f941ce31b257850e77a8335f74ba3a8a62914ad8c49ec21e076620444cf1c69
  SHA1=fda8c0871888d7d0fc1f06ed5739c6ac1585232c

Diffs from 12-20231215 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-12
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.