This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Detect UB in shifts in constexpr functions
- From: Marek Polacek <polacek at redhat dot com>
- To: Andreas Schwab <schwab at linux-m68k dot org>
- Cc: Jason Merrill <jason at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 3 Dec 2014 17:17:01 +0100
- Subject: Re: [C++ PATCH] Detect UB in shifts in constexpr functions
- Authentication-results: sourceware.org; auth=none
- References: <20141124155822 dot GQ29446 at redhat dot com> <20141124160508 dot GJ1674 at tucnak dot redhat dot com> <20141124164148 dot GR29446 at redhat dot com> <5476063A dot 7020200 at redhat dot com> <20141127142652 dot GC15555 at redhat dot com> <54788673 dot 9060000 at redhat dot com> <20141202141426 dot GQ15555 at redhat dot com> <547DD3CE dot 1010606 at redhat dot com> <20141202161353 dot GS15555 at redhat dot com> <87lhmo4zjl dot fsf at igel dot home>
On Wed, Dec 03, 2014 at 02:45:50PM +0100, Andreas Schwab wrote:
> Marek Polacek <polacek@redhat.com> writes:
>
> > * constexpr.c (cxx_eval_check_shift_p): New function.
> > (cxx_eval_binary_expression): Call it. Set NON_CONSTANT_P if it
> > returns true.
> >
> > * g++.dg/cpp0x/constexpr-shift1.C: New test.
> > * g++.dg/cpp1y/constexpr-shift1.C: New test.
> > * g++.dg/ubsan/pr63956.C: Add dg-errors.
>
> FAIL: 28_regex/algorithms/regex_match/ecma/wchar_t/anymatcher.cc (test for excess errors)
> Excess errors:
> /daten/aranym/gcc/gcc-20141203/Build/m68k-linux/libstdc++-v3/include/bits/regex_compiler.h:424:31: in constexpr expansion of 'std::__detail::_BracketMatcher< <template-parameter-1-1>, <anonymous>, <anonymous> >::_S_cache_size<std::regex_traits<wchar_t>, false, false>()'
> /daten/aranym/gcc/gcc-20141203/Build/m68k-linux/libstdc++-v3/include/bits/regex_compiler.h:425:20: error: right operand of shift expression '(1ul << 32u)' is >= than the precision of the left operand
> /daten/aranym/gcc/gcc-20141203/Build/m68k-linux/libstdc++-v3/include/bits/regex_compiler.h:424:31: in constexpr expansion of 'std::__detail::_BracketMatcher< <template-parameter-1-1>, <anonymous>, <anonymous> >::_S_cache_size<std::regex_traits<wchar_t>, false, true>()'
> /daten/aranym/gcc/gcc-20141203/Build/m68k-linux/libstdc++-v3/include/bits/regex_compiler.h:425:20: error: right operand of shift expression '(1ul << 32u)' is >= than the precision of the left operand
> /daten/aranym/gcc/gcc-20141203/Build/m68k-linux/libstdc++-v3/include/bits/regex_compiler.h:424:31: in constexpr expansion of 'std::__detail::_BracketMatcher< <template-parameter-1-1>, <anonymous>, <anonymous> >::_S_cache_size<std::regex_traits<wchar_t>, true, false>()'
> /daten/aranym/gcc/gcc-20141203/Build/m68k-linux/libstdc++-v3/include/bits/regex_compiler.h:425:20: error: right operand of shift expression '(1ul << 32u)' is >= than the precision of the left operand
> /daten/aranym/gcc/gcc-20141203/Build/m68k-linux/libstdc++-v3/include/bits/regex_compiler.h:424:31: in constexpr expansion of 'std::__detail::_BracketMatcher< <template-parameter-1-1>, <anonymous>, <anonymous> >::_S_cache_size<std::regex_traits<wchar_t>, true, true>()'
> /daten/aranym/gcc/gcc-20141203/Build/m68k-linux/libstdc++-v3/include/bits/regex_compiler.h:425:20: error: right operand of shift expression '(1ul << 32u)' is >= than the precision of the left operand
Should be fixed now.
Marek