This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/84400] New: “linux” string in path replaced when using “<>” angle brackets to include a header


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84400

            Bug ID: 84400
           Summary: “linux” string in path replaced when using “<>” angle
                    brackets to include a header
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mihaipop11 at gmail dot com
  Target Milestone: ---

I am using "Ubuntu 16.04.0 LTS" with: gcc version 5.4.0 20160609 (Ubuntu
5.4.0-6ubuntu1~16.04.6), but this problem can be reproduced on later gcc
versions as well, gcc-6 and gcc-7.

Here https://github.com/mihaipop11/gcc-linux you can find a link to a github
repo containing all the sources but i'll also explain this below.

How to reproduce:

We have this nice little program with these files:

// main.cpp
#include <iostream>
#include INCLUDE_FILE

int main()
{
  std::cout << "Works this time" << std::endl;
}
and a header file inside a folder, let's say named include, doesn't matter that
is empty, this is only for demonstration purposes.

// include.hpp
//empty header
Overall the structure looks like this:

<dir>
├── main.cpp
└── include
    └── include.hpp
Compilation step:

I analysed two cases and the bug appears in the second one.

First case:

The <dir> folder name which holds the files should be named anything but
something that contains the string linux. ex: test-notlinux

Overall the structure looks like this:

test-notlinux
├── main.cpp
└── include
    └── include.hpp
Now, cd test-notlinux and try to compile the sources:

g++ "-D INCLUDE_FILE=\"${PWD}/include/include.hpp\"" main.cpp
g++ "-D INCLUDE_FILE=<${PWD}/include/include.hpp>" main.cpp
Result: Both commands work as expected. No issue here.

Second case: The <dir> folder name which holds the files contains the string
linux. ex: test-linux

Overall the structure looks like this:

test-linux
├── main.cpp
└── include
    └── include.hpp
Now, cd test-linux and try to compile the sources:

// first command should work
g++ "-D INCLUDE_FILE=\"${PWD}/include/include.hpp\"" main.cpp

// but this ...
g++ "-D INCLUDE_FILE=<${PWD}/include/include.hpp>" main.cpp

Result: The second command apparently replaces the linux string from the dir
name with 1

Output: /tmp/test-1/include/include.hpp: No such file or directory

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]