[llvm-bugs] [Bug 42226] New: C18 standard conformance non-compliance.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 11 01:38:42 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42226

            Bug ID: 42226
           Summary: C18 standard conformance non-compliance.
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C
          Assignee: unassignedclangbugs at nondot.org
          Reporter: escanorexpress at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

This report is a technical point more than anything. Both the C90 and C18
standards have a "conformance chapter", chapter 4 on C18, that states the
following on section 1:


"In this International Standard, “shall” is to be interpreted as a requirement
on an implementation or on a program; conversely, “shall not” is to be
interpreted as a prohibition"


The technical point is the following, in section 5.1.1.2 in C18 , there is a
similar section in C90, phase 2 states the following:

"Each instance of a backslash character (\) immediately followed by a new-line
character is deleted, splicing physical source lines to form logical source
lines. Only the last backslash on any physical source line shall be eligible
for being part of such a splice. A source file that is not empty shall end in a
new-line character, which shall not be immediately preceded by a backslash
character before any such splicing takes place."

Consider the following program:

simple_case.c
"
int main(){ return 0; }
\
"

clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

gcc (Ubuntu 8.3.0-6ubuntu1~18.04) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


The clang version above compiles it just fine, and the gcc version above issues
the following warning:

"c.c:2:1: warning: backslash-newline at end of file
 \

"

If instead we have:

elaborate_case.c
"
int main(){ return 0; }
\

"

then they both compile fine without warning.

Question: according to the standard "A source file that is not empty shall end
in a new-line character, which shall not be immediately preceded by a backslash
character before any such splicing takes place.", are we not required by the
standard to treat such a text file, the elaborate_case.c,  as not a "source
file"? That is, it should not compile.

-- 
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/20190611/5f9aea26/attachment.html>


More information about the llvm-bugs mailing list