This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Potential Bug in GCC5?
- From: Gerald Pfeifer <gerald at pfeifer dot com>
- To: Yubin Ruan <ablacktshirt at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 10 Jun 2017 23:39:23 +0200 (CEST)
- Subject: Re: Potential Bug in GCC5?
- Authentication-results: sourceware.org; auth=none
- References: <20170610195128.GA6781@HP>
Hi Yubin,
On Sun, 11 Jun 2017, Yubin Ruan wrote:
> I don't know whether this bug has been reported(I have check GCC
> Bugzillia though) or has been resolved:
>
> This program:
>
> #include <stdio.h>
> int main()
> {
> char a = 'a';
> printf("Size of char : %d\n",sizeof(a));
> printf("Size of char : %d\n",sizeof('a'));
> return 0;
> }
>
> when compiled with:
>
> gcc -Wall testgcc.c -o testgcc -fexec-charset=utf-16
>
> will triggers GCC's bug report reminder:
>
> ...
> internal compiler error: character 0xa is not unibyte in execution character set
as a user / bug reporter I quite like internal compiler errors in
that there is no argument of whether there is a bug here or not. ;-)
(The question is whether it is what we call "ICE on valid", that is,
an internal compiler error on valid input, or "ICE on invalid", where
the latter is a bug as well, but clearly not as severe as the former.)
> Is it appropriate for me to create a bug report on GCC's bugzillia?
Yes. We prefer that you reproduce with a current version of GCC,
since for GCC 5 (let alone older) most new bug reports likely won't
be fixed any more, and newer versions may have fixed an issue already
after all, but in principle also accept reports against older versions.
I reproduced this with GCC 7.1.1 and filed a bug report:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81050
Gerald
PS: GCC 7.1.1 shows the following with -Wall, though -Wall is not
necessary to reproduce the issue:
x.c: In function ‘main’:
x.c:4:16: warning: multi-character character constant [-Wmultichar]
char a = 'a';
^~~
x.c:4:16: warning: overflow in implicit constant conversion [-Woverflow]
x.c:5:14: warning: embedded ‘\0’ in format [-Wformat-contains-nul]
printf("Size of char : %d\n",sizeof(a));
^~~~~~~~~~~~~~~~~~~~~
x.c:5:14: warning: too many arguments for format [-Wformat-extra-args]
x.c:6:43: warning: multi-character character constant [-Wmultichar]
printf("Size of char : %d\n",sizeof('a'));
^~~
x.c:6:14: warning: embedded ‘\0’ in format [-Wformat-contains-nul]
printf("Size of char : %d\n",sizeof('a'));
^~~~~~~~~~~~~~~~~~~~~
x.c:6:14: warning: too many arguments for format [-Wformat-extra-args]
x.c:8:0: internal compiler error: character 0xa is not unibyte in
execution character set
}
PPS: The warnings added with -Wall here don't appear to be helpful,
either. In fact, "embedded ‘\0’ in format" appears confusing/incorrect
to me?