A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/llvm/llvm-project/issues/56490 below:

[Modules] Incorrect ODR checks caused by `preferred_name` attribute. · Issue #56490 · llvm/llvm-project · GitHub

I met an incorrect ODR checks caused by preferred_name. Here is a reduced example.

// string_view.h
template<class _CharT>
class basic_string_view;

typedef basic_string_view<char> string_view;

template<class _CharT>
class
__attribute__((__preferred_name__(string_view)))
basic_string_view {
public:
    basic_string_view() 
    {
    }
};

inline basic_string_view<char> foo()
{
  return basic_string_view<char>();
}
// A.cppm
module;
#include "string_view.h"
export module A;

// Use.cppm
module;
#include "string_view.h"
export module Use;
import A;

The input command line is:

clang++ -std=c++20 --precompile A.cppm -o A.pcm
clang++ -std=c++20 --precompile Use.cppm -fprebuilt-module-path=.  -fsyntax-only

The output would be the incorrect ODR warning:

string_view.h:11:5: error: 'basic_string_view<char>::basic_string_view' from module 'A.<global>' is not present in definition of 'string_view' provided earlier

I've been fighting with the problem for several days. My current process is that when the ASTReader reads the preferred_name attribute, it would read the string_view type and find an existing one. However, the current behavior would create another RecordType for string_view despite there is already one. So here is the problem.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4