------- Comment #10 from rob1weld at aol dot com  2007-07-07 18:05 -------
I compiled the program I was working on using GCC 4.2 that was configured using
the option "--enable-concept-checks" and one file would not compile; giving
this error:

/usr/include/c++/4.2/bits/boost_concept_check.h: In member function 'void
__gnu_cxx::_InputIteratorConcept<_Tp>::__constraints() [with _Tp =
profile_t::const_iterator]':
/usr/include/c++/4.2/bits/boost_concept_check.h:63:   instantiated from 'void
__gnu_cxx::__function_requires() [with _Concept =
__gnu_cxx::_InputIteratorConcept<profile_t::const_iterator>]'
/usr/include/c++/4.2/bits/stl_numeric.h:84:   instantiated from '_Tp
std::accumulate(_InputIterator, _InputIterator, _Tp) [with _InputIterator =
profile_t::const_iterator, _Tp = long long unsigned int]'
/usr/include/c++/4.2/bits/boost_concept_check.h:456: error: no
'operator++(int)' declared for postfix '++', trying prefix operator instead


I recompiled that one file only using GCC 4.3 that was configured WITHOUT using
the option "--enable-concept-checks" and the file compiled fine. I ran "make
check" and all tests passed. 


I did some searching for the use of concept checks, first on my installed
files:

# grep -r GLIBCXX_CONCEPT_CHECKS /usr/include/*
/usr/include/c++/4.2/bits/concept_check.h:#ifndef _GLIBCXX_CONCEPT_CHECKS
/usr/include/c++/4.2/bits/c++config.h:#define _GLIBCXX_CONCEPT_CHECKS 1
Binary file /usr/include/c++/4.2/bits/stdc++.h.gch/O0g.gch matches
Binary file /usr/include/c++/4.2/bits/stdc++.h.gch/O2g.gch matches
Binary file /usr/include/c++/4.2/bits/stdtr1c++.h.gch/O2g.gch matches
/usr/include/c++/4.2/i686-pc-linux-gnu/bits/c++config.h:#define
_GLIBCXX_CONCEPT_CHECKS 1
Binary file /usr/include/c++/4.2/i686-pc-linux-gnu/bits/stdc++.h.gch/O0g.gch
matches
Binary file /usr/include/c++/4.2/i686-pc-linux-gnu/bits/stdc++.h.gch/O2g.gch
matches
Binary file /usr/include/c++/4.2/i686-pc-linux-gnu/bits/stdtr1c++.h.gch/O2g.gch
matches
/usr/include/c++/4.1.2/bits/concept_check.h:#ifndef _GLIBCXX_CONCEPT_CHECKS
/usr/include/c++/4.1.2/i486-linux-gnu/bits/c++config.h:/* #undef
_GLIBCXX_CONCEPT_CHECKS */
/usr/include/c++/4.1.2/i486-linux-gnu/64/bits/c++config.h:/* #undef
_GLIBCXX_CONCEPT_CHECKS */
/usr/include/c++/3.4/bits/concept_check.h:#ifndef _GLIBCXX_CONCEPT_CHECKS
/usr/include/c++/3.4/x86_64-linux-gnu/bits/c++config.h:/* #undef
_GLIBCXX_CONCEPT_CHECKS */
/usr/include/c++/3.4/i486-linux-gnu/bits/c++config.h:/* #undef
_GLIBCXX_CONCEPT_CHECKS */
/usr/include/c++/4.1/bits/concept_check.h:#ifndef _GLIBCXX_CONCEPT_CHECKS
/usr/include/c++/4.1/i486-linux-gnu/bits/c++config.h:/* #undef
_GLIBCXX_CONCEPT_CHECKS */
/usr/include/c++/4.1/i486-linux-gnu/64/bits/c++config.h:/* #undef
_GLIBCXX_CONCEPT_CHECKS */


Next, on GCC 4.3.0 source code (edited results - removed .html and ChangeLogs):

/root/downloads/gcc-4_3-trunk/libstdc++-v3/include/bits/concept_check.h
/root/downloads/gcc-4_3-trunk/libstdc++-v3/src/Makefile.in
/root/downloads/gcc-4_3-trunk/libstdc++-v3/src/concept-inst.cc
/root/downloads/gcc-4_3-trunk/libstdc++-v3/src/Makefile.am
/root/downloads/gcc-4_3-trunk/libstdc++-v3/configure
/root/downloads/gcc-4_3-trunk/libstdc++-v3/config.h.in
/root/downloads/gcc-4_3-trunk/libstdc++-v3/acinclude.m4


The file gcc-4_3-trunk/libstdc++-v3/docs/html/17_intro/howto.html says:

"Undefined by default. Configurable. When defined, performs compile-time
checking on certain template instantiations to detect violations of the
requirements of the standard."

It would be better if they were on by default - I can compile GCC 4.2 and 4.3
on target i686-pc-linux-gnu with them on. It seems unfortunate to have them
off.


This file obviously needs a little update but,
gcc-4_3-trunk/libstdc++-v3/docs/html/19_diagnostics/howto.html says:

"They are off by default for all versions of GCC from 3.0 to 3.4 (the latest
release at the time of writing). They can be enabled at configure time with
"--enable-concept-checks". You can enable them on a per-translation-unit basis
with "#define _GLIBCXX_CONCEPT_CHECKS" for GCC 3.4 and higher (or with
<code>#define _GLIBCPP_CONCEPT_CHECKS</code> for versions 3.1, 3.2 and 3.3)."


Reading that tells me that they are off by default and if you configure GCC
using "--enable-concept-checks" they are also automatically on for any code you
compile, thus the error message.


Suggested FIX:

The error message could be converted to a warning message _IF_ the compiler
detected the problem and instead of issuing an error message used a (NEW) GCC
command line switch "-fno-concept-checks" to disable the checks for the one
file - better yet, for the one function (or line of code!).

This would give us the benefit of concept checks without the problem of needing
to rewrite older code to avoid what is described as "Strange message when
operator++ not found". Indeed, if not strange it is a challenge for a non C++
programmer to figure out the line of source code at fault from the resulting
error message, 



A precident for adding a new GCC option ("-fno-concept-checks"), (or allowing
"-fpermissive" to en/disable it), is that when reading the gcc.info file,
section "C++ Dialect Options", I see that we have options like:

-fabi-version=N , -fno-access-control , -fcheck-new , -ffriend-injection ,
-fno-enforce-eh-specs , -ffor-scope , -fno-optional-diags , -fpermissive ,
-fuse-cxa-atexit , -fno-use-cxa-get-exception-ptr , -Wabi ... etc. 

IE: most of the options for C++ _are_ to permit violations of the standards.


Having concept check ON by default instead of OFF is better. It would not be
impossible to have them enabled and issue a warning instead of a multi-line
error message.

GCC 4.3.0 uses Boost version 1.12.0, but the newest version is 1.34.0, might
be that an upgrade would be a task to add to the job jar.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16696

Reply via email to