Skip to content

warn_no_constructor_for_refconst can not be disabled (Boost.ConceptCheck) #41104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mloskot opened this issue May 5, 2019 · 4 comments · Fixed by #136182
Closed

warn_no_constructor_for_refconst can not be disabled (Boost.ConceptCheck) #41104

mloskot opened this issue May 5, 2019 · 4 comments · Fixed by #136182
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party quality-of-implementation

Comments

@mloskot
Copy link

mloskot commented May 5, 2019

Bugzilla Link 41759
Version unspecified
OS Linux
CC @dwblaikie,@DougGregor,@mizvekov,@zygoloid

Extended Description

The warn_no_constructor_for_refconst (and possibly other from close category) can not be disabled as there is no corresponding -Wno flag available in clang++<=9.

This causes issues while compiling code that makes use of Boost.ConceptCheck library. For example:

#include <boost/concept_check.hpp>
int main()
{
    using T = int const&;
    boost::function_requires
        <
            boost::EqualityComparableConcept<T>
        >();
}

will trigger a flood of warnings:

$ clang++ -std=c++11 -I/mnt/d/boost.wsl clang_warn_no_constructor_for_refconst.cpp
In file included from clang_warn_no_constructor_for_refconst.cpp:1:
/mnt/d/boost.wsl/boost/concept_check.hpp:231:17: warning: struct 'EqualityComparable<const int &>' does not declare any constructor
      to initialize its non-modifiable members
  BOOST_concept(EqualityComparable,(TT))
                ^
/mnt/d/boost.wsl/boost/concept_check.hpp:231:17: note: in instantiation of template class 'boost::EqualityComparable<const int &>'
      requested here
/mnt/d/boost.wsl/boost/concept/detail/has_constraints.hpp:32:63: note: in instantiation of template class
      'boost::EqualityComparableConcept<const int &>' requested here
  inline yes has_constraints_(Model*, wrap_constraints<Model,&Model::constraints>* = 0);
                                                              ^
/mnt/d/boost.wsl/boost/concept/detail/has_constraints.hpp:44:25: note: while substituting deduced template arguments into function
      template 'has_constraints_' [with Model = boost::EqualityComparableConcept<const int &>]
      , value = sizeof( detail::has_constraints_((Model*)0) ) == sizeof(detail::yes) );
                        ^
/mnt/d/boost.wsl/boost/concept/detail/general.hpp:53:19: note: in instantiation of template class
      'boost::concepts::not_satisfied<boost::EqualityComparableConcept<const int &> >' requested here
        concepts::not_satisfied<Model>::value
                  ^
/mnt/d/boost.wsl/boost/concept_check.hpp:50:7: note: in instantiation of template class 'boost::concepts::requirement_<void
      (*)(boost::EqualityComparableConcept<const int &>)>' requested here
      BOOST_CONCEPT_ASSERT((Model));
      ^
/mnt/d/boost.wsl/boost/concept/assert.hpp:43:5: note: expanded from macro 'BOOST_CONCEPT_ASSERT'
    BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens)
    ^
/mnt/d/boost.wsl/boost/concept/detail/general.hpp:71:25: note: expanded from macro 'BOOST_CONCEPT_ASSERT_FN'
    &::boost::concepts::requirement_<ModelFnPtr>::failed>    \
                        ^
clang_warn_no_constructor_for_refconst.cpp:6:12: note: in instantiation of function template specialization
      'boost::function_requires<boost::EqualityComparableConcept<const int &> >' requested here
    boost::function_requires
           ^
/mnt/d/boost.wsl/boost/concept_check.hpp:238:8: note: reference member 'a' will never be initialized
    TT a, b;
       ^
/mnt/d/boost.wsl/boost/concept_check.hpp:238:11: note: reference member 'b' will never be initialized
    TT a, b;
          ^
1 warning generated.

There is no way to disable this

warning: struct 'EqualityComparable<const int &>' does not declare any constructor to initialize its non-modifiable members

Although I understand and agree with rationale provided by Chandler here https://softwareengineering.stackexchange.com/questions/122608/clang-warning-flags-for-objective-c-development/124574#124574, to warning about "never really correct" code, I think that in this particular use case of the Boost.ConceptCheck library, it is Okey to expect to be able to disable the warn_no_constructor_for_refconst (and similar).

The PITA is that for any non-trivial size of templated library that makes use of Boost.ConceptCheck, compilation with Clang leads to a flood of warning.
As side effect, it causes trouble when compiling on popular CI services available for open source projects (timeouts, builds killed due to logs too long etc.)

@mizvekov
Copy link
Contributor

I failed to reproduce this on compiler explorer.

If this is an issue only with old clang on old boost, I am not sure we can really do anything about it.

If you have more details or a standalone repro please reopen.

@mloskot
Copy link
Author

mloskot commented Jul 26, 2021

Screenshot with repro of the issue using clang 12 and Boost 1.77 (develop branch)
I can still reproduce the issue using clang 12 and Boost 1.77 (current develop branch):

$ clang++ --version | grep version
Ubuntu clang version 12.0.1-++20210630032618+fed41342a82f-1~exp1~20210630133332.127

$ grep '#define BOOST_VERSION ' /home/mloskot/boost/boost/version.hpp
#define BOOST_VERSION 107700
$ cat test.cpp
#include <boost/concept_check.hpp>
int main()
{
    using T = int const&;
    boost::function_requires<boost::EqualityComparableConcept<T>>();
}
$ clang++ -std=c++11 -I/home/mloskot/boost test.cpp
In file included from test.cpp:1:
/home/mloskot/boost/boost/concept_check.hpp:231:17: warning: struct 'EqualityComparable<const int &>' does not declare any constructor to initialize its non-modifiable members
  BOOST_concept(EqualityComparable,(TT))
                ^
/home/mloskot/boost/boost/concept_check.hpp:231:17: note: in instantiation of template class 'boost::EqualityComparable<const int &>' requested here
/home/mloskot/boost/boost/concept/detail/has_constraints.hpp:32:63: note: in instantiation of template class 'boost::EqualityComparableConcept<const int &>' requested here
  inline yes has_constraints_(Model*, wrap_constraints<Model,&Model::constraints>* = 0);
                                                              ^
/home/mloskot/boost/boost/concept/detail/has_constraints.hpp:44:25: note: while substituting deduced template arguments into function template 'has_constraints_' [with Model = boost::EqualityComparableConcept<const int &>]
      , value = sizeof( detail::has_constraints_((Model*)0) ) == sizeof(detail::yes) );
                        ^
/home/mloskot/boost/boost/concept/detail/general.hpp:74:19: note: in instantiation of template class 'boost::concepts::not_satisfied<boost::EqualityComparableConcept<const int &>>' requested here
        concepts::not_satisfied<Model>::value
                  ^
/home/mloskot/boost/boost/concept_check.hpp:50:7: note: in instantiation of template class 'boost::concepts::requirement_<void (*)(boost::EqualityComparableConcept<const int &>)>' requested here
      BOOST_CONCEPT_ASSERT((Model));
      ^
/home/mloskot/boost/boost/concept/assert.hpp:43:5: note: expanded from macro 'BOOST_CONCEPT_ASSERT'
    BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens)
    ^
/home/mloskot/boost/boost/concept/detail/general.hpp:92:25: note: expanded from macro 'BOOST_CONCEPT_ASSERT_FN'
    &::boost::concepts::requirement_<ModelFnPtr>::failed>    \
                        ^
test.cpp:5:12: note: in instantiation of function template specialization 'boost::function_requires<boost::EqualityComparableConcept<const int &>>' requested here
    boost::function_requires<boost::EqualityComparableConcept<T>>();
           ^
/home/mloskot/boost/boost/concept_check.hpp:238:8: note: reference member 'a' will never be initialized
    TT a, b;
       ^
/home/mloskot/boost/boost/concept_check.hpp:238:11: note: reference member 'b' will never be initialized
    TT a, b;
          ^
1 warning generated.

@mloskot
Copy link
Author

mloskot commented Jul 26, 2021

@​Matheus Izvekov

I asked here https://cpplang.slack.com/archives/C28NX7947/p1627297817121500
about why the Compiler Explorer is not showing the error and Matt Godbolt tweaked the command line, and the CE now also can reproduce the problem, see:

https://godbolt.org/z/os4YGMoe3

So, I've reopened the bug.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@Endilll Endilll changed the title warn_no_constructor_for_refconst can not be disabled (Boost.ConceptCheck) warn_no_constructor_for_refconst can not be disabled (Boost.ConceptCheck) Jul 19, 2024
@Endilll Endilll added the clang:to-be-triaged Should not be used for new issues label Jul 19, 2024
AaronBallman added a commit to AaronBallman/llvm-project that referenced this issue Apr 17, 2025
I put this under -Wunitialized because that's the same group it's under
in GCC.

Fixes llvm#41104
@AaronBallman AaronBallman added confirmed Verified by a second party clang:frontend Language frontend issues, e.g. anything involving "Sema" quality-of-implementation and removed clang:to-be-triaged Should not be used for new issues labels Apr 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 17, 2025

@llvm/issue-subscribers-clang-frontend

Author: Mateusz Łoskot (mloskot)

| | | | --- | --- | | Bugzilla Link | [41759](https://llvm.org/bz41759) | | Version | unspecified | | OS | Linux | | CC | @dwblaikie,@DougGregor,@mizvekov,@zygoloid |

Extended Description

The warn_no_constructor_for_refconst (and possibly other from close category) can not be disabled as there is no corresponding -Wno flag available in clang++<=9.

This causes issues while compiling code that makes use of Boost.ConceptCheck library. For example:

#include &lt;boost/concept_check.hpp&gt;
int main()
{
    using T = int const&amp;;
    boost::function_requires
        &lt;
            boost::EqualityComparableConcept&lt;T&gt;
        &gt;();
}

will trigger a flood of warnings:

$ clang++ -std=c++11 -I/mnt/d/boost.wsl clang_warn_no_constructor_for_refconst.cpp
In file included from clang_warn_no_constructor_for_refconst.cpp:1:
/mnt/d/boost.wsl/boost/concept_check.hpp:231:17: warning: struct 'EqualityComparable&lt;const int &amp;&gt;' does not declare any constructor
      to initialize its non-modifiable members
  BOOST_concept(EqualityComparable,(TT))
                ^
/mnt/d/boost.wsl/boost/concept_check.hpp:231:17: note: in instantiation of template class 'boost::EqualityComparable&lt;const int &amp;&gt;'
      requested here
/mnt/d/boost.wsl/boost/concept/detail/has_constraints.hpp:32:63: note: in instantiation of template class
      'boost::EqualityComparableConcept&lt;const int &amp;&gt;' requested here
  inline yes has_constraints_(Model*, wrap_constraints&lt;Model,&amp;Model::constraints&gt;* = 0);
                                                              ^
/mnt/d/boost.wsl/boost/concept/detail/has_constraints.hpp:44:25: note: while substituting deduced template arguments into function
      template 'has_constraints_' [with Model = boost::EqualityComparableConcept&lt;const int &amp;&gt;]
      , value = sizeof( detail::has_constraints_((Model*)0) ) == sizeof(detail::yes) );
                        ^
/mnt/d/boost.wsl/boost/concept/detail/general.hpp:53:19: note: in instantiation of template class
      'boost::concepts::not_satisfied&lt;boost::EqualityComparableConcept&lt;const int &amp;&gt; &gt;' requested here
        concepts::not_satisfied&lt;Model&gt;::value
                  ^
/mnt/d/boost.wsl/boost/concept_check.hpp:50:7: note: in instantiation of template class 'boost::concepts::requirement_&lt;void
      (*)(boost::EqualityComparableConcept&lt;const int &amp;&gt;)&gt;' requested here
      BOOST_CONCEPT_ASSERT((Model));
      ^
/mnt/d/boost.wsl/boost/concept/assert.hpp:43:5: note: expanded from macro 'BOOST_CONCEPT_ASSERT'
    BOOST_CONCEPT_ASSERT_FN(void(*)ModelInParens)
    ^
/mnt/d/boost.wsl/boost/concept/detail/general.hpp:71:25: note: expanded from macro 'BOOST_CONCEPT_ASSERT_FN'
    &amp;::boost::concepts::requirement_&lt;ModelFnPtr&gt;::failed&gt;    \
                        ^
clang_warn_no_constructor_for_refconst.cpp:6:12: note: in instantiation of function template specialization
      'boost::function_requires&lt;boost::EqualityComparableConcept&lt;const int &amp;&gt; &gt;' requested here
    boost::function_requires
           ^
/mnt/d/boost.wsl/boost/concept_check.hpp:238:8: note: reference member 'a' will never be initialized
    TT a, b;
       ^
/mnt/d/boost.wsl/boost/concept_check.hpp:238:11: note: reference member 'b' will never be initialized
    TT a, b;
          ^
1 warning generated.

There is no way to disable this

warning: struct 'EqualityComparable&lt;const int &amp;&gt;' does not declare any constructor to initialize its non-modifiable members

Although I understand and agree with rationale provided by Chandler here https://softwareengineering.stackexchange.com/questions/122608/clang-warning-flags-for-objective-c-development/124574#124574, to warning about "never really correct" code, I think that in this particular use case of the Boost.ConceptCheck library, it is Okey to expect to be able to disable the warn_no_constructor_for_refconst (and similar).

The PITA is that for any non-trivial size of templated library that makes use of Boost.ConceptCheck, compilation with Clang leads to a flood of warning.
As side effect, it causes trouble when compiling on popular CI services available for open source projects (timeouts, builds killed due to logs too long etc.)

IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
I put this under -Wunitialized because that's the same group it's under
in GCC.

Fixes llvm#41104
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this issue May 6, 2025
I put this under -Wunitialized because that's the same group it's under
in GCC.

Fixes llvm#41104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party quality-of-implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants