-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[modules] Compilation success depends on order of declarations in the modulemap #131814
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
Comments
@llvm/issue-subscribers-clang-modules Author: Louis Dionne (ldionne)
Consider the following set of headers:
// myvector.h
#ifndef MYVECTOR_H
#define MYVECTOR_H
#include <bit_ref.h>
template <class _Allocator>
struct MyVector {
typedef bool value_type;
typedef unsigned long __storage_type;
friend class MyBitIterator<MyVector, false>;
};
#endif // bit_ref.h
#ifndef BIT_REF_H
#define BIT_REF_H
#include <bit_ref_fwd.h>
#endif // bit_ref_fwd.h
#ifndef BIT_REF_FWD_H
#define BIT_REF_FWD_H
template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0>
class MyBitIterator {};
#endif And the following modulemap:
The following fails to compile:
The error is:
A few things can be observed:
Is this behavior intended? If the order of module definitions in a modulemap matters, there should be a warning that tells us when the compiler encounters something that has not been defined yet in the modulemap. If the order is irrelevant, then there's a bug in Clang. This was discovered while investigating #127015. |
Attaching a full reproducer. |
Consider the following set of headers:
And the following modulemap:
The following fails to compile:
The error is:
A few things can be observed:
bit_ref_fwd
andbit_ref
before the definition ofmyvector
in the modulemap, the issue goes away.export mystd.bit_ref
from themyvector
module, the issue goes away.#include <bit_ref_fwd.h>
inmyvector.h
, the issue goes away.Is this behavior intended? If the order of module definitions in a modulemap matters, there should be a warning that tells us when the compiler encounters something that has not been defined yet in the modulemap. If the order is irrelevant, then there's a bug in Clang.
This was discovered while investigating #127015.
The text was updated successfully, but these errors were encountered: