[llvm-bugs] [Bug 48749] New: clang allows goto inside statement expr

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 14 06:26:52 PST 2021


            Bug ID: 48749
           Summary: clang allows goto inside statement expr
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nbkolchin at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

The following obviously incorrect program compiles without error under clang
and clang++:

#include <stdio.h>

int main(int argc, char** argv)
    goto L_bug;
    printf("%s, %s %s\n", "Hello", ({ L_bug: ; "world!";}), "What?");

gcc produces error: "error: jump into statement expression". g++ accepts this
code. (gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98682)

Tested clang versions: 11.0.0 and "Apple clang version 12.0.0

This behaviour contradicts with documentation: "Jumping into a statement
expression with goto or using a switch statement outside the statement
expression with a case or default label inside the statement expression is not

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210114/9f983a1f/attachment-0001.html>

More information about the llvm-bugs mailing list