diff options
author | brucedawson <brucedawson@chromium.org> | 2015-01-21 14:02:16 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-21 22:03:10 +0000 |
commit | b132ccda867e4fc8479450db3baf96f1b713b827 (patch) | |
tree | 8267892ea3eef9e3793a7391430cd30a346dc09b /base/tuple.h | |
parent | 96f8d4195135b5ba13f07806fda07509b5907889 (diff) | |
download | chromium_src-b132ccda867e4fc8479450db3baf96f1b713b827.zip chromium_src-b132ccda867e4fc8479450db3baf96f1b713b827.tar.gz chromium_src-b132ccda867e4fc8479450db3baf96f1b713b827.tar.bz2 |
Avoid a /analyze internal compiler error with MakeIndexSequence
The recently added MakeIndexSequence templates cause a VC++ internal
compiler error when building with /analyze. This happens on dozens of
source files so disabling /analyze for those files is impractical. This
change conditionally replaces the template recursion with a
straightforward implementation for values from zero to five. This is
sufficient to build Chrome at the moment.
The code which VC++ doesn't like was introduced in change:
https://codereview.chromium.org/693693005
It's an ugly fix, but justified by the desire to allow running
/analyze. The /analyze version of the code will never be run.
A VC++ bug has been filed:
https://connect.microsoft.com/VisualStudio/feedback/details/1053626
BUG=427616
Review URL: https://codereview.chromium.org/803183004
Cr-Commit-Position: refs/heads/master@{#312469}
Diffstat (limited to 'base/tuple.h')
-rw-r--r-- | base/tuple.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/base/tuple.h b/base/tuple.h index 4408074..41c6a00 100644 --- a/base/tuple.h +++ b/base/tuple.h @@ -40,6 +40,50 @@ struct IndexSequence {}; template <size_t... Ns> struct MakeIndexSequenceImpl; +#if defined(_PREFAST_) && defined(OS_WIN) + +// Work around VC++ 2013 /analyze internal compiler error: +// https://connect.microsoft.com/VisualStudio/feedback/details/1053626 + +template <> struct MakeIndexSequenceImpl<0> { + using Type = IndexSequence<>; +}; +template <> struct MakeIndexSequenceImpl<1> { + using Type = IndexSequence<0>; +}; +template <> struct MakeIndexSequenceImpl<2> { + using Type = IndexSequence<0,1>; +}; +template <> struct MakeIndexSequenceImpl<3> { + using Type = IndexSequence<0,1,2>; +}; +template <> struct MakeIndexSequenceImpl<4> { + using Type = IndexSequence<0,1,2,3>; +}; +template <> struct MakeIndexSequenceImpl<5> { + using Type = IndexSequence<0,1,2,3,4>; +}; +template <> struct MakeIndexSequenceImpl<6> { + using Type = IndexSequence<0,1,2,3,4,5>; +}; +template <> struct MakeIndexSequenceImpl<7> { + using Type = IndexSequence<0,1,2,3,4,5,6>; +}; +template <> struct MakeIndexSequenceImpl<8> { + using Type = IndexSequence<0,1,2,3,4,5,6,7>; +}; +template <> struct MakeIndexSequenceImpl<9> { + using Type = IndexSequence<0,1,2,3,4,5,6,7,8>; +}; +template <> struct MakeIndexSequenceImpl<10> { + using Type = IndexSequence<0,1,2,3,4,5,6,7,8,9>; +}; +template <> struct MakeIndexSequenceImpl<11> { + using Type = IndexSequence<0,1,2,3,4,5,6,7,8,9,10>; +}; + +#else // defined(WIN) && defined(_PREFAST_) + template <size_t... Ns> struct MakeIndexSequenceImpl<0, Ns...> { using Type = IndexSequence<Ns...>; @@ -49,6 +93,8 @@ template <size_t N, size_t... Ns> struct MakeIndexSequenceImpl<N, Ns...> : MakeIndexSequenceImpl<N - 1, N - 1, Ns...> {}; +#endif // defined(WIN) && defined(_PREFAST_) + template <size_t N> using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::Type; |