<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/93859>93859</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Mixing #include, import std, and -fexperimental-modules-reduced-bmi leads to strange error message
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rnikander
      </td>
    </tr>
</table>

<pre>
    Usually I can reduce a bug to just a couple files. But as I try to boil down my "real" code here, every time I delete a line, the error goes away. So at the moment I'm left with *seven* tiny files, which import each other and use bits of the standard library. Probably there is a more to delete, but I give up for now. 

Here they are gzipped and attached. There should be a shell script there to compile them. The script will need to be tweaked to fit your environment. 

[Reduced_BMI_Issue.tgz](https://github.com/llvm/llvm-project/files/15504372/Reduced_BMI_Issue.tgz)

In the real code I did not `#include <string>` as in this example. Instead, I included a boost header. If we are not allowed to mix `#include <some-std-header>` and `import std`, then the compiler needs to give better error messages about this. It is very easy to have a #include buried somewhere in a global fragment, especially when you are trying to wrap old libraries in modules. 

This error message sent me in the wrong direction and wasted a lot of time. If you play with the code you can see that changing weird, seemingly unrelated things -- like deleting a use of `push_back` or a variable of `std::set<int>`, in seemingly random files - all these changes can trigger or un-trigger the error. So it sends you down rabbit holes, confusing you about the cause of the error.


```
In module 'std' imported from ImageView.ixx:3:
/Users/rob/Dev/llvm-project/build_phase2_x86_macos/include/c++/v1/__algorithm/unwrap_range.h:65:12: error: no viable constructor or deduction guide for deduction of template arguments of 'pair'
   65 |     return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
      | ^
/Users/rob/Dev/llvm-project/build_phase2_x86_macos/include/c++/v1/__algorithm/unwrap_range.h:76:45: note: in instantiation of member function 'std::__unwrap_range_impl<unsigned int *, unsigned int *>::__unwrap' requested here
   76 |   return __unwrap_range_impl<_Iter, _Sent>::__unwrap(std::move(__first), std::move(__last));
      | ^
/Users/rob/Dev/llvm-project/build_phase2_x86_macos/include/c++/v1/__algorithm/copy_move_common.h:94:24: note: in instantiation of function template specialization 'std::__unwrap_range<unsigned int *, unsigned int *>' requested here
   94 |   auto __range  = std::__unwrap_range(__first, std::move(__last));
 | ^
/Users/rob/Dev/llvm-project/build_phase2_x86_macos/include/c++/v1/__algorithm/copy.h:109:15: note: in instantiation of function template specialization 'std::__copy_move_unwrap_iters<std::__copy_impl<std::_ClassicAlgPolicy>, unsigned int *, unsigned int *, unsigned int *, 0>' requested here
  109 | return std::__copy_move_unwrap_iters<__copy_impl<_AlgPolicy> >(
      | ^
/Users/rob/Dev/llvm-project/build_phase2_x86_macos/include/c++/v1/__algorithm/copy.h:116:15: note: in instantiation of function template specialization 'std::__copy<std::_ClassicAlgPolicy, unsigned int *, unsigned int *, unsigned int *>' requested here
  116 |   return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second;
      | ^
ImageView.ixx:13:10: note: in instantiation of function template specialization 'std::__nikander::copy<unsigned int *, unsigned int *>' requested here
   17 |     std::copy(idxs, idxs + 6, oidxs);
 | ^
/Users/rob/Dev/llvm-project/build_phase2_x86_macos/include/c++/v1/__utility/pair.h:63:29: note: candidate function template not viable: requires 1 argument, but 2 were provided
   63 | struct _LIBCPP_TEMPLATE_VIS pair
      | ^~~~
1 error generated.
```


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMmF1v2zrSgH8NfTOwIVP-iC984Tg1XgOnQPG259wKlDiWeEqRWpKy4170ty-GlB2nyaYnOLvbDQw7ovgxM8_MaEbCe1UbxDWb37P5w0j0obFu7Yz6KoxENyqtPK9_973Q-gx7qIQBh7KvEASUfQ3Bwp-9DyCgsn2nEQ5Ko5_AfR9AeNhDcGeaVFqlQdqTgfYMjHOHQjPOobISoUGHjG8Bj0izVYuwB4kaAx2jlYl3Q4OAzlkHtUUP4iTOE_hsQYR4q7UtmgB7xpctaDwEOKnQAOM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