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

    <tr>
        <th>Summary</th>
        <td>
            scan-build with gcc/clang mismatching default c++std
        </td>
    </tr>

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

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

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

<pre>
    When both clang and gcc are installed, in my case, clang(14) defaults to c++14, and gcc(12.2) defaults to c++17.

And the default compiler is gcc.

You may get unexplained compiler errors in your scan-build output. 
This is because scan-build does not automatically add an explicit `-std=c++17` to the clang compiler command-line it uses internally.

I ran into this problem with a cmake based project.  cmake omits unnecessary compiler flags depending on your compiler version. You can of course add the `-std=...` option explicitly, but that does not make the project files any prettier.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0U8GOozgQ_RpzKQWBE9LhwKF7WpH2vtJqj4VdAe8aG7nKM8vfr0wyyfRhLiCo51fvPVchs5sC0aC6D9V9VphljmkI3gkvVI3RbsNfMwUYo8xgPIYJMFiYjAFMBC6woPdklf4GLsCygUGm8rWDlb60J6V7sHTD7IVBIhilP5T-KIVvP9kKUNf6d9C3WjWfqnm_P9-DBZnpJxJMXFbnKYHjwvUF-3fMsOAGEwnkQP-tHl0g-zpDKcXERfwWcwI2GA5jdt5CzLJmqeFO9OfsuDQYyWBm-hVoIzGEKIBZ4oLiDHq_AVoLGKD0dMYJqHNzYLHq-Pm0pc5NsVnM3MN9yjJxWTDYg3eBwAlkpiJSKIVC_sXjH5AwlGJhcgxriqOnBX44mQHBLPgvwYhMtpT-ISM1PP7GxQlDDoEMMWPaXgpuHicGSysF68IE8ZHQE_CdErsYaigZGwwQb2BiTky79WLqZbmu62I2ruLiKxO_lRkYs4DMKK8gd22F4KEXbs4TA4YN1kQijtIjgcoOR9sfe6xoaM9v_fHSt01XzcPbSZvbSZuL7sejvWDfXtqmv7QGm_akyVRu0I0-NkfdNpfuorvadLcOza1vbr0xOHbq1NCCztfef1_qmKbKMWcazm33dq48juR5XxytA_2Avai0LnuUhnLmMOaJ1anxjoVfLOLE0_DL_Oz3tC_B9T4Fi-MFxcwl9ueQ32eGxVY5-WEWWVkd35W-Kn2dnMx5rE1clL6WRo_X4ZGf0tddHit93eX_HwAA___m1lGx">