On 7/10/19 1:23 PM, Gabriel Dos Reis wrote:

On Jul 10, 2019, at 10:18 AM, Tom Honermann <tom@honermann.net> wrote:

On 7/10/19 1:00 PM, Gabriel Dos Reis via Modules wrote:

On Jul 10, 2019, at 6:27 AM, Bryce Adelstein Lelbach aka wash <brycelelbach@gmail.com> wrote:

On Wed, Jul 10, 2019 at 2:48 AM Gabriel Dos Reis via SG15
<sg15@lists.isocpp.org> wrote:
Also, we should note that import and #include of the same file can lead to unexpected results, so we need both clarifications and recommendations there for users.
Why should this lead to unexpected results?

Suppose I have:

#include <foo>
import <foo>;
To illustrate the concern, let me further add that the header <foo> has include guard and all that.

The #include copy-n-pastes the content of foo in the current translation - including of course any definitions.  The import makes available any declaration/definition from the translation unit of foo.  The program ends up with multiple definitions (at link time at least).
This doesn't sound correct to me.

For <foo> to be importable at all implies, to me, that the implementation must be aware (somehow) that <foo> designates an importable header.  In other words, in this scenario, no copy-n-paste inclusion occurs.

[module.import]p5 (https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Feel.is%2Fc%2B%2Bdraft%2Fmodule.import%235&amp;data=02%7C01%7Cgdr%40microsoft.com%7C627c2e697d3246f69cd008d7055aaa49%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C1%7C636983759279843021&amp;sdata=KNmreH81AE1GNzLjcAEgzCneqRsmQy%2BhWsuAdwN64qU%3D&amp;reserved=0):

... An importable header is a member of an implementation-defined set of headers ...
Please expand on how it doesn’t sound correct.  All I said follows exactly the spec. 

For <foo> to be an importable header, per [module.import]p5, it "is a member of an implementation-defined set of headers".  If <foo> is an importable header, then, per [cpp.include]p7, "the preprocessing directive is instead replaced by the preprocessing-tokens 'import header-name ;'"  Headers that are importable headers are not textually included.

Tom.