Skip to content

Structures that were not declared as "export" were abnormally exported #143734

@hexne

Description

@hexne

/// bp.cppm

module;
#include <memory>
#include <vector>
export module bp;

struct Layer {  
    void forward(int) {  }
};

export class BP {
    std::vector<std::shared_ptr<Layer>> layers_;
};

/// cnn.cppm

module;
#include <memory>
#include <vector>
export module cnn;

import bp;

struct Layer { 
    void forward() {  }
};

export
class CNN {
    std::vector<std::shared_ptr<Layer>> layouts_;
};

command:

clang++ -std=c++20 --precompile bp.cppm -o bp.pcm
clang++ -std=c++20 --precompile cnn.cppm -o cnn.pcm -fprebuilt-module-path=.

error message:

cnn.cppm:8:8: error: declaration 'Layer' attached to named module 'cnn' cannot be attached to other modules
    8 | struct Layer { 
      |        ^
/home/hexne/Projects/modforge/bp.cppm:6:8: note: also found
    6 | struct Layer {  
      |        ^
/home/hexne/Projects/modforge/bp.cppm:7:10: error: 'Layer::forward' from module 'bp' is not present in definition of 'Layer' provided earlier
    7 |     void forward(int) {  }
      |          ^
cnn.cppm:9:10: note: declaration of 'forward' does not match
    9 |     void forward() {  }
      |          ^
2 errors generated.

Metadata

Metadata

Assignees

Labels

clang:modulesC++20 modules and Clang Header Modules

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions