Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__builtin_FILE() is inconsistent on path separator on Windows #45076

Open
SuperWig opened this issue Apr 29, 2020 · 1 comment
Open

__builtin_FILE() is inconsistent on path separator on Windows #45076

SuperWig opened this issue Apr 29, 2020 · 1 comment
Labels
bugzilla Issues migrated from bugzilla c++20 clang:to-be-triaged Should not be used for new issues platform:windows

Comments

@SuperWig
Copy link

SuperWig commented Apr 29, 2020

Bugzilla Link 45731
Version 10.0
OS Windows NT
CC @AaronBallman,@amccarth-google,@zygoloid,@rnk

Extended Description

Given the following

src/main.cpp
src/header.h

And the following code:

header.h:

#include <iostream>

void test()
{
    std::cout << __builtin_FILE() << '\n';
}

main.cpp:

#include "header.h"

int main()
{
    test();
    std::cout << __builtin_FILE() << '\n';
}

I get the following output

src/header.h
src\main.cpp

Discovered this when implementing std::source_location for Microsoft here

microsoft/STL#664 (comment)

@rnk
Copy link
Collaborator

rnk commented May 5, 2020

Clang internally does as little path canonicalization as possible, although I've forgotten precisely why, and this behavior is a reflection of that. __FILE__ has the same issue. This results in user-supplied paths often containing backslashes (-IC:\my~8.3\sdk\path) being concatenated with portable separators (forward slashes) and traversal components (..). It has long been suggested that this is not what users want to see in __FILE__, but changing __FILE__ is of course fraught with peril.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@SuperWig SuperWig changed the title __builtin_FUNCTION() is inconsistent on path separator on Windows __builtin_FILE() is inconsistent on path separator on Windows Feb 28, 2022
@Endilll Endilll changed the title __builtin_FILE() is inconsistent on path separator on Windows __builtin_FILE() is inconsistent on path separator on Windows Jul 18, 2024
@Endilll Endilll added the clang:to-be-triaged Should not be used for new issues label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++20 clang:to-be-triaged Should not be used for new issues platform:windows
Projects
Status: No status
Development

No branches or pull requests

4 participants