public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@mengyan1223.wang>
To: 3497650172 <3497650172@qq.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: 回复: Inconsistency with C language standard
Date: Thu, 14 Oct 2021 23:24:34 +0800	[thread overview]
Message-ID: <bebd00238a86359266e5e34cb130154b32e73940.camel@mengyan1223.wang> (raw)
In-Reply-To: <tencent_7A3E0B9A44D54C42051CA77EC71741F55005@qq.com>

On Thu, 2021-10-14 at 20:58 +0800, 3497650172 wrote:
> In Visual Studio, if the value of enumeration constant exceeds the
> range that int can represent, hermit conversion will be performed,
> such as the following code:
> ————————————————————————
> #include<stdio.h>
> 
> enum A {
> 	MAX= 4294967295
> };
> int main() {
> 	if (MAX < 1) {
> 		printf("test");
> 	}
> }
> ————————————————————————
> In Visual Studio, the value of Max is - 1, so "test" will be output.
> but in GCC, the value of Max is 4294967295, so "test" will not be
> output.
> I think the Visual Studio is consistent with the C language standard,
> but GCC is inconsistent with the standard.

As I've explained, you are invoking undefined behavior, so a conforming
compiler can do anything.

The standard is not "you think".

-- 
Xi Ruoyao <xry111@mengyan1223.wang>
School of Aerospace Science and Technology, Xidian University

      parent reply	other threads:[~2021-10-14 15:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14  2:28 3497650172
2021-10-14  6:38 ` Jonathan Wakely
2021-10-14 10:46   ` Xi Ruoyao
     [not found]     ` <tencent_7A3E0B9A44D54C42051CA77EC71741F55005@qq.com>
2021-10-14 15:24       ` Xi Ruoyao [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bebd00238a86359266e5e34cb130154b32e73940.camel@mengyan1223.wang \
    --to=xry111@mengyan1223.wang \
    --cc=3497650172@qq.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).