<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Lower limit of availability attribute isn't enforced"
   href="https://bugs.llvm.org/show_bug.cgi?id=46747">46747</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Lower limit of availability attribute isn't enforced
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Malcolm_Ferguson@yahoo.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following does not produce an error.  I expect it should:
$ cat << EOF | ./clang -x c - -mmacosx-version-min=10.9
__attribute__((availability(macosx,introduced=10.10,deprecated=10.11,obsoleted=10.12)))
int fn(void) { return 1; }
int main() { return fn(); }
EOF

If I set -mmacosx-version-min=10.11, clang issues a warning.  If I set it to
10.12, clang issues an error.  It handles the upper limit of the availibity
attribute, but not the lower limit.

This was a problem for us compiling Python3 to run on macOS 10.9 using a modern
version of Xcode.  The fdopendir() function was added to dirent.h in
MacOSX10.10.sdk and is available on systems running macOS 10.10 or later.  The
autoconf script for Python detects that fdopendir is available and uses this
instead of opendir(), but it wouldn't do this if clang issued an error.  This
led to runtime fails on the min. supported system.  We build all of our
products this way, which means we run the risk of accidentally using functions
that aren't available.

Apple's dirent.h declares:
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
DIR *fdopendir(int) __DARWIN_ALIAS_I(fdopendir);

Which preprocesses to:
# 128
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/dirent.h"
3 4
__attribute__((availability(macosx,introduced=10.10)))
DIR *fdopendir(int) __asm("_" "fdopendir" "$INODE64" );</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>