CXX on X86 : Crah when VERSION.; is in an included directory

Post Reply

Topic author
joukj
Master
Posts: 178
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

CXX on X86 : Crah when VERSION.; is in an included directory

Post by joukj » Thu Jul 27, 2023 6:03 am

Hi all,

When VERSION.; is in a directory that is to be searched by the CXX-compiler, released a few days ago, it crashes. (see example below). This did not happen with the previous CXX-compiler

Code: Select all

rumba-jj) cxx/vers
clang version 10.0.1 (git@bitbucket.org:vms_software/llvm-10.0.1.git 1a6bcdeb1db
d320d5898ab7723bb691325ce8bd5)
Build date: 07-18-2023
Target: x86_64-OpenVMS
Thread model: posix
InstalledDir: RUMBA$DKA100:[SYS0.SYSCOMMON.][SYSEXE]
rumba-jj) dir 

Directory $DISK0:[JOUKJ.test.bugs.cxx.include]

test.cxx;99         VERSION.;1          

Total of 2 files.
rumba-jj) ty VERSION.
0.15.1b
configure.ac:24
id3tag.h:338-341
msvc++/config.h:59,65,71

Makefile.am:63-65
rumba-jj) ty test.cxx
#include <math.h>
#include <stdio.h>
#include <inttypes.h>

int main()
{
   return 0;
}
rumba-jj) cxx/inc=[] test.cxx
In file included from $DISK0:[JOUKJ.test.bugs.cxx.include]test.cxx;99:1:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/math.h:317:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/type_traits
:423:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/cstddef:43:
[]version:1:1: error: expected unqualified-id
0.15.1b
^
In file included from $DISK0:[JOUKJ.test.bugs.cxx.include]test.cxx;99:1:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/math.h:317:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/type_traits
:423:
/SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/cstddef:55:9: error: no member na
med 'ptrdiff_t' in the global namespace
using ::ptrdiff_t;
      ~~^
In file included from $DISK0:[JOUKJ.test.bugs.cxx.include]test.cxx;99:1:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/math.h:317:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/type_traits
:424:
[]version:1:1: error: expected unqualified-id
0.15.1b
^
In file included from $DISK0:[JOUKJ.test.bugs.cxx.include]test.cxx;99:1:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/math.h:318:
In file included from /SYS$COMMON/VSICXX$LIB/INCLUDE/LIB_CXX/INCLUDE/limits:127:
[]version:1:1: error: expected unqualified-id
0.15.1b
^
4 errors generated.
rumba-jj)


jreagan
VSI Expert
Master
Posts: 141
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: CXX on X86 : Crah when VERSION.; is in an included directory

Post by jreagan » Tue Aug 08, 2023 3:30 pm

Thanks. We recently added support for TLBs and must have messed up something else.


jreagan
VSI Expert
Master
Posts: 141
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: CXX on X86 : Crah when VERSION.; is in an included directory

Post by jreagan » Mon Aug 28, 2023 3:54 pm

So this program has caused lots of heated discussion on the team. :D

The issue is that the /INCLUDE=[] qualifier affects both "quoted" includes and <angle-bracket> includes.

Looking at the Itanium C++ help file, you see

For standard searches, the search order is as follows:

1. Search the current directory (directory of the source
being processed). If angle-bracket form, search only if no
directories are specified with /INCLUDE_DIRECTORY.

2. Search the locations specified in the /INCLUDE_DIRECTORY
qualifier (if any).

And on x86, the STL headers, currently shipped as unique files in (we aren't sure about putting them into a TLB in the future since the directory isn't flat anymore)

SYS$COMMON:[VSICXX$LIB.INCLUDE.lib_cxx.include]


Your example does an

#include <math.h>

On Itanium, there is no math.h in CXXL$ANSI_DEF so the compiler uses the one in SYS$LIBRARY:DECC$RTLDEF.TLB. It only includes <decc$types.h> and <fp_class.h>

On x86, there is a C++ unique version of math.h in the STL headers from LLVM. It also lives in the same directory as math.h. That header now includes <type_traits> (and since you don't have one, we find and use the one from the same CXX directory). Then <type_traits> contains an

#include <version>

and with the /INCLUDE=[] on the command line, the compiler finds YOUR version header and not the one that comes with the STL headers.

You can see the same thing on Itanium if you have a name conflict with a header that comes with the system in the TLBs.

Traditionally, our /INCLUDE impacts both quoted-string and angle-bracket includes. clang does have an option to include a name on the include path only for quoted-string includes. Using it, the compiler would find the correct version header for the include from <type_traits>.

cxx/clang=("-iquote","[]")

TL;DR We think the compiler is behaving correctly but the addition of more headers in the set of C++ supplied headers can cause these porting issues.


Topic author
joukj
Master
Posts: 178
Joined: Thu Aug 27, 2020 5:50 am
Reputation: 0
Status: Offline

Re: CXX on X86 : Crah when VERSION.; is in an included directory

Post by joukj » Mon Sep 04, 2023 7:01 am

Is this the same problem as I reported in viewtopic.php?f=12&t=8780 ??

Post Reply