[Bug 209877] #defining lint trashes _Noreturn, violating C11

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue May 31 00:09:56 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209877

            Bug ID: 209877
           Summary: #defining lint trashes _Noreturn, violating C11
           Product: Base System
           Version: 10.3-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: standards
          Assignee: freebsd-standards at FreeBSD.org
          Reporter: eggert at cs.ucla.edu

A user ran into a problem when building bleeding-edge Emacs and I tracked it
down to a compatibility issue with FreeBSD's use of the 'lint' macro in C. You
can see the original problem report in <http://bugs.gnu.org/23640> (originally
about Cygwin, but look for "FreeBSD" later on in the bug report).

FreeBSD doesn't conform to the C standard in this area. To reproduce the
conformance bug, compile the following three-line file t.c:

#define lint 1
#include <stdio.h>
_Noreturn int x;

This C program violates a constraint because _Noreturn is allowed only on
function declarations. The C compiler is therefore required to issue a
diagnostic. However, the shell command 'cc -std=c11 -S t.c' silently ignores
the _Noreturn.

The problem is that FreeBSD headers in /usr/include define _Noreturn to be
empty if the symbol 'lint' is defined. But 'lint' is in user space, and users
programs are allowed to use it for whatever they want. That's what Emacs was
doing, and other programs are like Emacs in this respect, so the problem won't
go away by my simply modifying GNU Emacs to use some symbol other than 'lint'.

I suppose that one possible fix would be for cdefs.h to define its own symbol
_FreeBSD_Noreturn instead of defining _Noreturn, and for other headers to use
_FreeBSD_Noreturn rather than _Noreturn.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-standards mailing list