public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "john at johnmaddock dot co dot uk" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/13554] New: static_cast fails in Boost.Math library
Date: Sat, 03 Jan 2004 11:54:00 -0000	[thread overview]
Message-ID: <20040103115450.13554.john@johnmaddock.co.uk> (raw)

I have a corner case where a static cast fails if the target type has an 
explicit constructor, the case is abstacted from the Boost.Math library, and 
compiles OK with VC++7.1 and EDG-frontend compilers, the failure seems to be a 
regression from previous gcc releases:

namespace boost{

template<typename T, template<typename> class U>
U<T> test(const U<T>& t)
{
  U<T> x = static_cast<U<T> >(1);
  return t + x;
}

namespace nested{

template <class T>
struct numeric
{
  numeric(){ m_value = 0; }
  explicit numeric(T t){ m_value = t; }
  T value()const { return m_value; }
  private:
  T m_value;
};

template <class T>
numeric<T> operator+(const numeric<T>& a, const numeric<T>& b)
{
  return numeric<T>(a.value() + b.value());
}

}

}

int main()
{
   boost::nested::numeric<double> num(2);
   boost::test(num);
   return 0;
}

-- 
           Summary: static_cast fails in Boost.Math library
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: john at johnmaddock dot co dot uk
                CC: gcc-bugs at gcc dot gnu dot org


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


             reply	other threads:[~2004-01-03 11:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-03 11:54 john at johnmaddock dot co dot uk [this message]
2004-01-03 12:07 ` [Bug c++/13554] " pinskia at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040103115450.13554.john@johnmaddock.co.uk \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).