VS 2015 - 错误C1001优化开启时

时间:2016-04-11 14:57:04

标签: c++ visual-studio compiler-errors

我已将项目从Visual Studio 2012升级到2015年。

在调试模式下构建时,构建成功完成。

然而,在发布模式下,我收到错误C1001 编译器中发生了内部错误。如果我将优化设置为禁用,则错误消失 - 但这样不是解决方案。我希望能够通过优化来编译我的项目。

错误发生在 xlocnum 文件中(据我所知,它是标准库的一部分)。

滚动到代码段的末尾,查看产生错误的行。

// TEMPLATE CLASS numpunct
template<class _Elem>
class numpunct
: public locale::facet
{    // facet for defining numeric punctuation text
    public:
    typedef basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> >
    string_type;
    typedef _Elem char_type;

    __PURE_APPDOMAIN_GLOBAL _CRTIMP2_PURE static locale::id id;    // unique facet id

    _Elem decimal_point() const
    {    // return decimal point
        return (do_decimal_point());
    }

    _Elem thousands_sep() const
    {    // return thousands separator
        return (do_thousands_sep());
    }

    string grouping() const
    {    // return grouping string
        return (do_grouping());
    }

    string_type falsename() const
    {    // return name for false
        return (do_falsename());
    }

    string_type truename() const
    {    // return name for true
        return (do_truename());
    }

    explicit numpunct(size_t _Refs = 0)
    : locale::facet(_Refs)
    {    // construct from current locale
        _BEGIN_LOCINFO(_Lobj)
        _Init(_Lobj);
        if (_Kseparator == 0)
        _Kseparator =    // NB: differs from "C" locale
        _MAKLOCCHR(_Elem, ',', _Lobj._Getcvt());
        _END_LOCINFO()
    }

    numpunct(const _Locinfo& _Lobj, size_t _Refs = 0, bool _Isdef = false)
    : locale::facet(_Refs)
    {    // construct from specified locale
        _Init(_Lobj, _Isdef);
    }

    static size_t _Getcat(const locale::facet **_Ppf = 0,
    const locale *_Ploc = 0)
    {    // return locale category mask and construct standard facet
        if (_Ppf != 0 && *_Ppf == 0)
        *_Ppf = new numpunct<_Elem>(
        _Locinfo(_Ploc->c_str()), 0, true);
        return (_X_NUMERIC);
    }

    protected:
    virtual __CLR_OR_THIS_CALL ~numpunct() _NOEXCEPT
    {    // destroy the object
        _Tidy();
    }

    numpunct(const char *_Locname, size_t _Refs = 0, bool _Isdef = false)
    : locale::facet(_Refs)
    {    // construct from specified locale
        _BEGIN_LOCINFO(_Lobj(_Locname))
        _Init(_Lobj, _Isdef);
        _END_LOCINFO()
    }

    template<class _Elem2>
    void _Getvals(_Elem2, const lconv *_Ptr, _Locinfo::_Cvtvec _Cvt)
    {    // get values
        _Dp = _MAKLOCCHR(_Elem2, _Ptr->decimal_point[0], _Cvt);
        _Kseparator = _MAKLOCCHR(_Elem2, _Ptr->thousands_sep[0], _Cvt);
    }

    template<>
    void _Getvals(wchar_t, const lconv *_Ptr, _Locinfo::_Cvtvec)
    {    // get values
        _Dp = (_Elem)_Ptr->_W_decimal_point[0];
        _Kseparator = (_Elem)_Ptr->_W_thousands_sep[0];
    }

    void _Init(const _Locinfo& _Lobj, bool _Isdef = false)
    {    // initialize from _Lobj
        const lconv *_Ptr = _Lobj._Getlconv();
        _Locinfo::_Cvtvec _Cvt = _Lobj._Getcvt();    // conversion information

        _Grouping = 0;
        _Falsename = 0;
        _Truename = 0;

        _TRY_BEGIN
        _Grouping = _MAKLOCSTR(char, _Isdef ? "" : _Ptr->grouping,
        _Lobj._Getcvt());
        _Falsename = _MAKLOCSTR(_Elem, _Lobj._Getfalse(), _Cvt);
        _Truename = _MAKLOCSTR(_Elem, _Lobj._Gettrue(), _Cvt);
        _CATCH_ALL
        _Tidy();
        _RERAISE;
        _CATCH_END

        if (_Isdef)
        {    // apply defaults for required facets
            //            _Grouping = _MAKLOCSTR(char, "", _Cvt);
            _Dp = _MAKLOCCHR(_Elem, '.', _Cvt);
            _Kseparator = _MAKLOCCHR(_Elem, ',', _Cvt);
        }
        else
        _Getvals((_Elem)0, _Ptr, _Cvt);
    }

    virtual _Elem __CLR_OR_THIS_CALL do_decimal_point() const
    {    // return decimal point
        return (_Dp);
    }

    virtual _Elem __CLR_OR_THIS_CALL do_thousands_sep() const
    {    // return thousands separator
        return (_Kseparator);
    }

    virtual string __CLR_OR_THIS_CALL do_grouping() const
    {    // return grouping string
        return (string(_Grouping));
    }

    virtual string_type __CLR_OR_THIS_CALL do_falsename() const
    {    // return name for false
        return (string_type(_Falsename));
    }

    virtual string_type __CLR_OR_THIS_CALL do_truename() const
    {    // return name for true
        return (string_type(_Truename));
    }

    private:
    void _Tidy()
    {    // free all storage
        _CSTD free((void *)_Grouping); // <---- ERROR HERE
        _CSTD free((void *)_Falsename);
        _CSTD free((void *)_Truename);
    }

    const char *_Grouping;    // grouping string, "" for "C" locale
    _Elem _Dp;    // decimal point, '.' for "C" locale
    _Elem _Kseparator;    // thousands separator, '' for "C" locale
    const _Elem *_Falsename;    // name for false, "false" for "C" locale
    const _Elem *_Truename;    // name for true, "true" for "C" locale
    };

0 个答案:

没有答案