diff --git a/conans/client/graph/compatibility.py b/conans/client/graph/compatibility.py index 967ddc90efe..1d67e7cf5e6 100644 --- a/conans/client/graph/compatibility.py +++ b/conans/client/graph/compatibility.py @@ -41,8 +41,8 @@ def cppstd_compat(conanfile): cppstd_possible_values = supported_cppstd(conanfile) if cppstd_possible_values is None: conanfile.output.warning(f'No cppstd compatibility defined for compiler "{compiler}"') - else: - factors.append([{"compiler.cppstd": v} for v in cppstd_possible_values if v != cppstd]) + else: # The current cppst must be included in case there is other factor + factors.append([{"compiler.cppstd": v} for v in cppstd_possible_values]) if compiler == "msvc": msvc_fallback = {"194": "193"}.get(compiler_version) diff --git a/conans/test/integration/package_id/test_cache_compatibles.py b/conans/test/integration/package_id/test_cache_compatibles.py index 702b11e6d90..1e235895286 100644 --- a/conans/test/integration/package_id/test_cache_compatibles.py +++ b/conans/test/integration/package_id/test_cache_compatibles.py @@ -398,6 +398,13 @@ def test_msvc_194_fallback(self): assert "mylib/1.0: Main binary package 'e340edd75790e7156c595edebd3d98b10a2e091e' missing."\ f"Using compatible package '{package_id1}'" + c.run("install --requires=mylib/1.0@ -s os=Windows -s arch=x86_64 -s build_type=Release " + "-s compiler=msvc " + "-s compiler.version=194 -s compiler.cppstd=17 " + "-s compiler.runtime=dynamic -pr:b=profile_build") + assert "mylib/1.0: Main binary package 'e340edd75790e7156c595edebd3d98b10a2e091e' missing." \ + f"Using compatible package '{package_id1}'" + class TestErrorsCompatibility: """ when the plugin fails, we want a clear message and a helpful trace