<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Bug im MS-Complier VC8.0]]></title><description><![CDATA[<p>folgender Code führt zu einem Compilefehler</p>
<pre><code class="language-cpp">#include &lt;boost/type_traits/is_integral.hpp&gt;
#include &lt;boost/utility/enable_if.hpp&gt;

#include &lt;iostream&gt;

class X
{
    struct enabler {};
public:
    template&lt; typename E &gt;
    X( E c, typename boost::enable_if&lt; boost::is_integral&lt; E &gt;, enabler &gt;::type = enabler() ) 
        : m_c(static_cast&lt; unsigned char &gt;( c )) {}

    template&lt; typename E, typename Traits &gt; friend
        std::basic_ostream&lt; E, Traits &gt;&amp; operator&lt;&lt;( std::basic_ostream&lt; E, Traits &gt;&amp; out, X x );

private: 
    unsigned char m_c;
};

template&lt; typename E, typename Traits &gt;
std::basic_ostream&lt; E, Traits &gt;&amp; operator&lt;&lt;( std::basic_ostream&lt; E, Traits &gt;&amp; out, X x )
{
    return out &lt;&lt; x.m_c;
};

class Foo
{
public:
    Foo( )
        : m_out( 0 )
    {}

    template&lt; typename I &gt;
    void put( I first, I last )
    {
        for( ; first != last; ++first )
            std::cout &lt;&lt; X( *first );
    }

private:
    std::ostream m_out;
};

void test( Foo* s )
{
    std::cout &lt;&lt; 'x';
    const char txt[] = &quot;123456&quot;;
    s-&gt;put( txt, txt + 4 );
}
</code></pre>
<p>Fehler:</p>
<pre><code>main_ng.cpp(11) : fatal error C1004: unexpected end-of-file found
        main_ng.cpp(49) : see reference to function template instantiation 'void Foo::put&lt;const char*&gt;(I,I)' being compiled
1&gt;        with
1&gt;        [
1&gt;            I=const char *
1&gt;        ]
</code></pre>
<p>Der Hinweis auf Zeile 11 und Zeile 49 stimmt mit dem Listing oben überein.</p>
<p>Der Compilefehler verschwindet, wenn ich die Zeile 47 weglasse oder(!) wenn ich die Zeile 49 weglasse oder(!) wenn ich den Member m_out Zeile 42 weglasse (obwohl der gar nicht benutzt wird) oder wenn ich das boost::enable_if weglasse.</p>
<p>Meines Erachtens ist das ein Bug im MS-Compiler - oder habt Ihr eine andere Idee.</p>
<p>Die boost-Version ist im Original 1.35. Und mit V1.41 habe ich das gleiche Verhalten.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/271687/bug-im-ms-complier-vc8-0</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 07:51:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/271687.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 02 Aug 2010 11:17:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Bug im MS-Complier VC8.0 on Mon, 02 Aug 2010 11:22:28 GMT]]></title><description><![CDATA[<p>folgender Code führt zu einem Compilefehler</p>
<pre><code class="language-cpp">#include &lt;boost/type_traits/is_integral.hpp&gt;
#include &lt;boost/utility/enable_if.hpp&gt;

#include &lt;iostream&gt;

class X
{
    struct enabler {};
public:
    template&lt; typename E &gt;
    X( E c, typename boost::enable_if&lt; boost::is_integral&lt; E &gt;, enabler &gt;::type = enabler() ) 
        : m_c(static_cast&lt; unsigned char &gt;( c )) {}

    template&lt; typename E, typename Traits &gt; friend
        std::basic_ostream&lt; E, Traits &gt;&amp; operator&lt;&lt;( std::basic_ostream&lt; E, Traits &gt;&amp; out, X x );

private: 
    unsigned char m_c;
};

template&lt; typename E, typename Traits &gt;
std::basic_ostream&lt; E, Traits &gt;&amp; operator&lt;&lt;( std::basic_ostream&lt; E, Traits &gt;&amp; out, X x )
{
    return out &lt;&lt; x.m_c;
};

class Foo
{
public:
    Foo( )
        : m_out( 0 )
    {}

    template&lt; typename I &gt;
    void put( I first, I last )
    {
        for( ; first != last; ++first )
            std::cout &lt;&lt; X( *first );
    }

private:
    std::ostream m_out;
};

void test( Foo* s )
{
    std::cout &lt;&lt; 'x';
    const char txt[] = &quot;123456&quot;;
    s-&gt;put( txt, txt + 4 );
}
</code></pre>
<p>Fehler:</p>
<pre><code>main_ng.cpp(11) : fatal error C1004: unexpected end-of-file found
        main_ng.cpp(49) : see reference to function template instantiation 'void Foo::put&lt;const char*&gt;(I,I)' being compiled
1&gt;        with
1&gt;        [
1&gt;            I=const char *
1&gt;        ]
</code></pre>
<p>Der Hinweis auf Zeile 11 und Zeile 49 stimmt mit dem Listing oben überein.</p>
<p>Der Compilefehler verschwindet, wenn ich die Zeile 47 weglasse oder(!) wenn ich die Zeile 49 weglasse oder(!) wenn ich den Member m_out Zeile 42 weglasse (obwohl der gar nicht benutzt wird) oder wenn ich das boost::enable_if weglasse.</p>
<p>Meines Erachtens ist das ein Bug im MS-Compiler - oder habt Ihr eine andere Idee.</p>
<p>Die boost-Version ist im Original 1.35. Und mit V1.41 habe ich das gleiche Verhalten.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935103</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935103</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Mon, 02 Aug 2010 11:22:28 GMT</pubDate></item><item><title><![CDATA[Reply to Bug im MS-Complier VC8.0 on Mon, 02 Aug 2010 12:07:13 GMT]]></title><description><![CDATA[<p>mit VS 2010 und boost 1.43 compiliert es.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935126</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935126</guid><dc:creator><![CDATA[also]]></dc:creator><pubDate>Mon, 02 Aug 2010 12:07:13 GMT</pubDate></item><item><title><![CDATA[Reply to Bug im MS-Complier VC8.0 on Mon, 02 Aug 2010 13:00:12 GMT]]></title><description><![CDATA[<p>also schrieb:</p>
<blockquote>
<p>mit VS 2010 und boost 1.43 compiliert es.</p>
</blockquote>
<p>Danke für die Info - wobei zwischen dem C++-Compiler vom VS 2005 (=V8.0) und dem von VC2010 wohl ein Riesenunterschied besteht.</p>
<p>Kann es nochmal jemand mit VC++8.0 (alias VS 2005) ausprobieren.</p>
<p>Wie melde ich so einen Fehler (wenn es denn einer ist) an Microsoft. Aus der MSDN werde ich da nicht schlau.</p>
<p>Gruß<br />
Werner</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935151</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935151</guid><dc:creator><![CDATA[Werner Salomon]]></dc:creator><pubDate>Mon, 02 Aug 2010 13:00:12 GMT</pubDate></item><item><title><![CDATA[Reply to Bug im MS-Complier VC8.0 on Mon, 02 Aug 2010 13:54:56 GMT]]></title><description><![CDATA[<p>Visual C++ 2008 kompiliert es nicht, selbe Fehlermeldung wie geposted.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935170</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935170</guid><dc:creator><![CDATA[Tobias Gerg]]></dc:creator><pubDate>Mon, 02 Aug 2010 13:54:56 GMT</pubDate></item><item><title><![CDATA[Reply to Bug im MS-Complier VC8.0 on Mon, 02 Aug 2010 14:02:04 GMT]]></title><description><![CDATA[<p>Mit VS2005 kann ich das auch reproduzieren. Es verschwindet auch wenn put keine template methode ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1935177</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1935177</guid><dc:creator><![CDATA[evilissimo]]></dc:creator><pubDate>Mon, 02 Aug 2010 14:02:04 GMT</pubDate></item></channel></rss>