public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* possible bug in gcc compiler
@ 2022-03-11 19:53 Larry Jackson
  2022-03-11 20:00 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Larry Jackson @ 2022-03-11 19:53 UTC (permalink / raw)
  To: gcc

I goofed and failed to put a space after the "case" word:

switch(nu){
case1: v1 =val;break;
case2: v2 =val;break;
case3: v3 =val;break;
case4: v4 =val;break;
}

gcc compiler showed NO errors or warnings. Execution of the code produced incorrect results.
After I added a space(no other changes), everything compiled and ran perfectly.

switch(nu){
case 1: v1 =val;break;
case 2: v2 =val;break;
case 3: v3 =val;break;
case 4: v4 =val;break;
}
version info:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1

Apple clang version 13.0.0 (clang-1300.0.29.30)

Target: x86_64-apple-darwin20.6.0

Thread model: posix

InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Thanks,
wl jackson

Sent with [ProtonMail](https://protonmail.com/) secure email.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: possible bug in gcc compiler
  2022-03-11 19:53 possible bug in gcc compiler Larry Jackson
@ 2022-03-11 20:00 ` Jakub Jelinek
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2022-03-11 20:00 UTC (permalink / raw)
  To: Larry Jackson; +Cc: gcc

Note, this mailing list is for development of gcc, gcc-help
would be more appropriate.

On Fri, Mar 11, 2022 at 07:53:32PM +0000, Larry Jackson via Gcc wrote:
> I goofed and failed to put a space after the "case" word:
> 
> switch(nu){
> case1: v1 =val;break;
> case2: v2 =val;break;
> case3: v3 =val;break;
> case4: v4 =val;break;
> }

That is valid code, case1: etc. is a user label, you could goto case1; to
reach it etc.  So no wonder you don't get any diagnostics.

> Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
> 
> Apple clang version 13.0.0 (clang-1300.0.29.30)

This means you even aren't using gcc at all but a different compiler.

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-11 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-11 19:53 possible bug in gcc compiler Larry Jackson
2022-03-11 20:00 ` Jakub Jelinek

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