]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/12226 (g++ fails to enforce accessibility requirement for copy constructor)
authorMark Mitchell <mark@codesourcery.com>
Sun, 4 Jan 2004 22:42:22 +0000 (22:42 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 4 Jan 2004 22:42:22 +0000 (22:42 +0000)
PR c++/12226
* call.c (CHECK_COPY_CONSTRUCTOR_P): New macro.
(reference_binding): Set it when appropriate.
(build_temp): New function, split out from ...
(convert_like_real): ... here.  Honor CHECK_COPY_CONSTRUCTOR_P.
(initialize_reference): Likewise.

PR c++/12226
* g++.dg/init/copy7.c: New test.

PR c++/12226
* testsuite/27_io/basic_filebuf/4.cc: Remove use of invalid copy
constructor.
* testsuite/27_io/basic_fstream/4.cc: Likewise.
* testsuite/27_io/basic_ifstream/4.cc: Likewise.
* testsuite/27_io/basic_ios/4.cc: Likewise.
* testsuite/27_io/basic_iostream/4.cc: Likewise.
* testsuite/27_io/basic_istream/4.cc: Likewise.
* testsuite/27_io/basic_istingstream/4.cc: Likewise.
* testsuite/27_io/basic_ofstream/4.cc: Likewise.
* testsuite/27_io/basic_ostream/4.cc: Likewise.
* testsuite/27_io/basic_ostringstream/4.cc: Likewise.
* testsuite/27_io/basic_stringbuf/5.cc: Likewise.
* testsuite/27_io/basic_stringstream/4.cc: Likewise.

PR c++/13536
* parser.c (cp_parser): Add in_type_id_in_expr_p.
(cp_parser_new): Initialize it.
(cp_parser_postfix_expression): Set it.
(cp_parser_sizeof_operand): Likewise.
(cp_parser_parameteR_declaration): Do not commit early to tenative
parsers when in_type_id_in_expr_p is set.

PR c++/13536
* g++.dg/parse/cast1.C: New test.

From-SVN: r75397

19 files changed:
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/copy7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/cast1.C [new file with mode: 0644]
libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/27_io/basic_filebuf/4.cc
libstdc++-v3/testsuite/27_io/basic_fstream/4.cc
libstdc++-v3/testsuite/27_io/basic_ifstream/4.cc
libstdc++-v3/testsuite/27_io/basic_ios/4.cc
libstdc++-v3/testsuite/27_io/basic_iostream/4.cc
libstdc++-v3/testsuite/27_io/basic_istream/4.cc
libstdc++-v3/testsuite/27_io/basic_istringstream/4.cc
libstdc++-v3/testsuite/27_io/basic_ofstream/4.cc
libstdc++-v3/testsuite/27_io/basic_ostream/4.cc
libstdc++-v3/testsuite/27_io/basic_ostringstream/4.cc
libstdc++-v3/testsuite/27_io/basic_stringbuf/5.cc
libstdc++-v3/testsuite/27_io/basic_stringstream/4.cc

index 897f8461d78c80cb24847c701d43779990dbaedc..08600f7a7a9bb97ca1f076369e224b21d6d999a8 100644 (file)
@@ -1,3 +1,20 @@
+2004-01-04  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/12226
+       * call.c (CHECK_COPY_CONSTRUCTOR_P): New macro.
+       (reference_binding): Set it when appropriate.
+       (build_temp): New function, split out from ...
+       (convert_like_real): ... here.  Honor CHECK_COPY_CONSTRUCTOR_P.
+       (initialize_reference): Likewise.
+
+       PR c++/13536
+       * parser.c (cp_parser): Add in_type_id_in_expr_p.
+       (cp_parser_new): Initialize it.
+       (cp_parser_postfix_expression): Set it.
+       (cp_parser_sizeof_operand): Likewise.
+       (cp_parser_parameteR_declaration): Do not commit early to tenative
+       parsers when in_type_id_in_expr_p is set.
+
 2004-01-03  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/13094
index 5e75925901512c6f19f31aa117de8e37684843e6..46ebca522539c51bc8e10fa0dff4177dd603e1fc 100644 (file)
@@ -497,6 +497,10 @@ struct z_candidate GTY(()) {
    should be created to hold the result of the conversion.  */
 #define NEED_TEMPORARY_P(NODE) TREE_LANG_FLAG_4 (NODE)
 
+/* TRUE in an IDENTITY_CONV or BASE_CONV if the copy constructor must
+   be accessible, even though it is not being used.  */
+#define CHECK_COPY_CONSTRUCTOR_P(NODE) TREE_LANG_FLAG_5 (NODE)
+
 #define USER_CONV_CAND(NODE) WRAPPER_ZC (TREE_OPERAND (NODE, 1))
 #define USER_CONV_FN(NODE) (USER_CONV_CAND (NODE)->fn)
 
@@ -1176,7 +1180,9 @@ reference_binding (tree rto, tree rfrom, tree expr, int flags)
   if (CLASS_TYPE_P (from) && compatible_p)
     {
       conv = build1 (IDENTITY_CONV, from, expr);
-      return direct_reference_binding (rto, conv);
+      conv = direct_reference_binding (rto, conv);
+      CHECK_COPY_CONSTRUCTOR_P (TREE_OPERAND (conv, 0)) = 1;
+      return conv;
     }
 
   /* [dcl.init.ref]
@@ -3952,6 +3958,34 @@ enforce_access (tree basetype_path, tree decl)
   return true;
 }
 
+/* Initialize a temporary of type TYPE with EXPR.  The FLAGS are a
+   bitwise or of LOOKUP_* values.  If any errors are warnings are
+   generated, set *DIAGNOSTIC_FN to "error" or "warning",
+   respectively.  If no diagnostics are generated, set *DIAGNOSTIC_FN
+   to NULL.  */
+
+static tree
+build_temp (tree expr, tree type, int flags, 
+           void (**diagnostic_fn)(const char *, ...))
+{
+  int savew, savee;
+
+  savew = warningcount, savee = errorcount;
+  expr = build_special_member_call (NULL_TREE, 
+                                   complete_ctor_identifier,
+                                   build_tree_list (NULL_TREE, expr), 
+                                   TYPE_BINFO (type),
+                                   flags);
+  if (warningcount > savew)
+    *diagnostic_fn = warning;
+  else if (errorcount > savee)
+    *diagnostic_fn = error;
+  else
+    *diagnostic_fn = NULL;
+  return expr;
+}
+           
+
 /* Perform the conversions in CONVS on the expression EXPR.  FN and
    ARGNUM are used for diagnostics.  ARGNUM is zero based, -1
    indicates the `this' argument of a method.  INNER is nonzero when
@@ -3964,9 +3998,8 @@ static tree
 convert_like_real (tree convs, tree expr, tree fn, int argnum, int inner,
                   bool issue_conversion_warnings)
 {
-  int savew, savee;
-
   tree totype = TREE_TYPE (convs);
+  void (*diagnostic_fn)(const char *, ...);
 
   if (ICS_BAD_FLAG (convs)
       && TREE_CODE (convs) != USER_CONV
@@ -4038,35 +4071,24 @@ convert_like_real (tree convs, tree expr, tree fn, int argnum, int inner,
        if (IS_AGGR_TYPE (totype)
            && (inner >= 0 || !lvalue_p (expr)))
          {
-           savew = warningcount, savee = errorcount;
-           expr = build_special_member_call
-             (NULL_TREE, complete_ctor_identifier,
-              build_tree_list (NULL_TREE, expr), TYPE_BINFO (totype),
-              /* Core issue 84, now a DR, says that we don't allow UDCs
-                 for these args (which deliberately breaks copy-init of an
-                 auto_ptr<Base> from an auto_ptr<Derived>).  */
-              LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING|LOOKUP_NO_CONVERSION);
-
-           /* Tell the user where this failing constructor call came from.  */
-           if (fn)
+           expr = (build_temp 
+                   (expr, totype, 
+                    /* Core issue 84, now a DR, says that we don't
+                       allow UDCs for these args (which deliberately
+                       breaks copy-init of an auto_ptr<Base> from an
+                       auto_ptr<Derived>).  */
+                    LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING|LOOKUP_NO_CONVERSION,
+                    &diagnostic_fn));
+                   
+           if (diagnostic_fn)
              {
-               if (warningcount > savew)
-                 warning
+               if (fn)
+                 diagnostic_fn 
                    ("  initializing argument %P of `%D' from result of `%D'",
                     argnum, fn, convfn);
-               else if (errorcount > savee)
-                 error
-                   ("  initializing argument %P of `%D' from result of `%D'",
-                    argnum, fn, convfn);
-             }
-           else
-             {
-               if (warningcount > savew)
-                 warning ("  initializing temporary from result of `%D'",
-                             convfn);
-               else if (errorcount > savee)
-                 error ("  initializing temporary from result of `%D'",
-                           convfn);
+               else
+                diagnostic_fn 
+                  ("  initializing temporary from result of `%D'",  convfn);
              }
            expr = build_cplus_new (totype, expr);
          }
@@ -4081,7 +4103,13 @@ convert_like_real (tree convs, tree expr, tree fn, int argnum, int inner,
       if (inner >= 0
          && TREE_CODE (TREE_TYPE (expr)) != ARRAY_TYPE)
        expr = decl_constant_value (expr);
-      return expr;
+      if (CHECK_COPY_CONSTRUCTOR_P (convs))
+       /* Generate a temporary copy purely to generate the required
+          diagnostics.  */
+       build_temp (build_dummy_object (totype), totype, 
+                   LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING,
+                   &diagnostic_fn);
+       return expr;
     case AMBIG_CONV:
       /* Call build_user_type_conversion again for the error.  */
       return build_user_type_conversion
@@ -4108,11 +4136,17 @@ convert_like_real (tree convs, tree expr, tree fn, int argnum, int inner,
        {
          /* We are going to bind a reference directly to a base-class
             subobject of EXPR.  */
-         tree base_ptr = build_pointer_type (totype);
-
+         if (CHECK_COPY_CONSTRUCTOR_P (convs))
+           /* Generate a temporary copy purely to generate the required
+              diagnostics.  */
+           build_temp (build_dummy_object (TREE_TYPE (expr)),
+                       TREE_TYPE (expr),
+                       LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING,
+                       &diagnostic_fn);
          /* Build an expression for `*((base*) &expr)'.  */
          expr = build_unary_op (ADDR_EXPR, expr, 0);
-         expr = perform_implicit_conversion (base_ptr, expr);
+         expr = perform_implicit_conversion (build_pointer_type (totype), 
+                                             expr);
          expr = build_indirect_ref (expr, "implicit conversion");
          return expr;
        }
@@ -4120,18 +4154,10 @@ convert_like_real (tree convs, tree expr, tree fn, int argnum, int inner,
       /* Copy-initialization where the cv-unqualified version of the source
         type is the same class as, or a derived class of, the class of the
         destination [is treated as direct-initialization].  [dcl.init] */
-      savew = warningcount, savee = errorcount;
-      expr = build_special_member_call (NULL_TREE, complete_ctor_identifier,
-                                       build_tree_list (NULL_TREE, expr),
-                                       TYPE_BINFO (totype),
-                                       LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING);
-      if (fn)
-       {
-         if (warningcount > savew)
-           warning ("  initializing argument %P of `%D'", argnum, fn);
-         else if (errorcount > savee)
-           error ("  initializing argument %P of `%D'", argnum, fn);
-       }
+      expr = build_temp (expr, totype, LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING,
+                        &diagnostic_fn);
+      if (diagnostic_fn && fn)
+       diagnostic_fn ("  initializing argument %P of `%D'", argnum, fn);
       return build_cplus_new (totype, expr);
 
     case REF_BIND:
@@ -6205,6 +6231,14 @@ initialize_reference (tree type, tree expr, tree decl, tree *cleanup)
         remember that the conversion was required.  */
       if (TREE_CODE (conv) == BASE_CONV && !NEED_TEMPORARY_P (conv))
        {
+         void (*diagnostic_fn) (const char *, ...);
+         if (CHECK_COPY_CONSTRUCTOR_P (conv))
+           /* Generate a temporary copy purely to generate the required
+              diagnostics.  */
+           build_temp (build_dummy_object (TREE_TYPE (expr)),
+                       TREE_TYPE (expr),
+                       LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING,
+                       &diagnostic_fn);
          base_conv_type = TREE_TYPE (conv);
          conv = TREE_OPERAND (conv, 0);
        }
index e62288c051eac3fa24be0cd85962dc856bc7597a..2edc777df8ec52b172ec0b945ed95240ba7371d0 100644 (file)
@@ -1257,6 +1257,11 @@ typedef struct cp_parser GTY(())
      statement.  */
   bool in_switch_statement_p;
 
+  /* TRUE if we are parsing a type-id in an expression context.  In
+     such a situation, both "type (expr)" and "type (type)" are valid
+     alternatives.  */
+  bool in_type_id_in_expr_p;
+
   /* If non-NULL, then we are parsing a construct where new type
      definitions are not permitted.  The string stored here will be
      issued as an error message if a type is defined.  */
@@ -2254,6 +2259,9 @@ cp_parser_new (void)
   /* We are not in a switch statement.  */
   parser->in_switch_statement_p = false;
 
+  /* We are not parsing a type-id inside an expression.  */
+  parser->in_type_id_in_expr_p = false;
+
   /* The unparsed function queue is empty.  */
   parser->unparsed_functions_queues = build_tree_list (NULL_TREE, NULL_TREE);
 
@@ -3468,6 +3476,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p)
       {
        tree type;
        const char *saved_message;
+       bool saved_in_type_id_in_expr_p;
 
        /* Consume the `typeid' token.  */
        cp_lexer_consume_token (parser->lexer);
@@ -3481,7 +3490,10 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p)
           expression.  */
        cp_parser_parse_tentatively (parser);
        /* Try a type-id first.  */
+       saved_in_type_id_in_expr_p = parser->in_type_id_in_expr_p;
+       parser->in_type_id_in_expr_p = true;
        type = cp_parser_type_id (parser);
+       parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
        /* Look for the `)' token.  Otherwise, we can't be sure that
           we're not looking at an expression: consider `typeid (int
           (3))', for example.  */
@@ -3572,12 +3584,16 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p)
            && cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN))
          {
            tree initializer_list = NULL_TREE;
+           bool saved_in_type_id_in_expr_p;
 
            cp_parser_parse_tentatively (parser);
            /* Consume the `('.  */
            cp_lexer_consume_token (parser->lexer);
            /* Parse the type.  */
+           saved_in_type_id_in_expr_p = parser->in_type_id_in_expr_p;
+           parser->in_type_id_in_expr_p = true;
            type = cp_parser_type_id (parser);
+           parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
            /* Look for the `)'.  */
            cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
            /* Look for the `{'.  */
@@ -4713,10 +4729,13 @@ cp_parser_cast_expression (cp_parser *parser, bool address_p)
        cp_parser_simulate_error (parser);
       else
        {
+         bool saved_in_type_id_in_expr_p = parser->in_type_id_in_expr_p;
+         parser->in_type_id_in_expr_p = true;
          /* Look for the type-id.  */
          type = cp_parser_type_id (parser);
          /* Look for the closing `)'.  */
          cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
+         parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
        }
 
       /* Restore the saved message.  */
@@ -10955,9 +10974,16 @@ cp_parser_parameter_declaration (cp_parser *parser,
   
       /* After seeing a decl-specifier-seq, if the next token is not a
         "(", there is no possibility that the code is a valid
-        expression initializer.  Therefore, if parsing tentatively,
-        we commit at this point.  */
+        expression.  Therefore, if parsing tentatively, we commit at
+        this point.  */
       if (!parser->in_template_argument_list_p
+         /* Having seen:
+
+              (int((char *)...
+
+            we cannot be sure whether we are looking at a
+            function-type (taking a */
+         && !parser->in_type_id_in_expr_p
          && cp_parser_parsing_tentatively (parser)
          && !cp_parser_committed_to_tentative_parse (parser)
          && cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_PAREN))
@@ -14473,6 +14499,7 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword)
   if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_PAREN))
     {
       tree type;
+      bool saved_in_type_id_in_expr_p;
 
       /* We can't be sure yet whether we're looking at a type-id or an
         expression.  */
@@ -14480,7 +14507,10 @@ cp_parser_sizeof_operand (cp_parser* parser, enum rid keyword)
       /* Consume the `('.  */
       cp_lexer_consume_token (parser->lexer);
       /* Parse the type-id.  */
+      saved_in_type_id_in_expr_p = parser->in_type_id_in_expr_p;
+      parser->in_type_id_in_expr_p = true;
       type = cp_parser_type_id (parser);
+      parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
       /* Now, look for the trailing `)'.  */
       cp_parser_require (parser, CPP_CLOSE_PAREN, "`)'");
       /* If all went well, then we're done.  */
index 0b82e5877c89c0ef4d3b4b90fa9f7291c7835367..e80100144f3a8525b8397dc387aeb3fd9116d326 100644 (file)
@@ -1,3 +1,11 @@
+2004-01-04  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/12226
+       * g++.dg/init/copy7.c: New test.
+
+       PR c++/13536
+       * g++.dg/parse/cast1.C: New test.
+
 2004-01-04  Jan Hubicka  <jh@suse.cz>
 
        * gcc.dg/winline[1-7].c: New tests.
diff --git a/gcc/testsuite/g++.dg/init/copy7.C b/gcc/testsuite/g++.dg/init/copy7.C
new file mode 100644 (file)
index 0000000..da447fa
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/12226
+
+class foo {
+private:
+  foo(const foo &);
+public:
+  foo();
+};
+const foo &bar = foo();
+
+class derived : public foo {
+private:
+  derived(const derived&);
+public:
+  derived();
+};
+
+const foo& baz = derived();
diff --git a/gcc/testsuite/g++.dg/parse/cast1.C b/gcc/testsuite/g++.dg/parse/cast1.C
new file mode 100644 (file)
index 0000000..0428526
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/13536
+// { dg-options "-w" }
+
+#include <typeinfo>
+
+void f() {
+  (int((char*)0));
+  sizeof ((int((char*)0)));
+  typeid ((int((char*)0)));
+}
index a2c78c0e6b5b1bfeca36c4db8ec1a3df8e5e6ea5..9ff75067f6ef7e3649f95de27e852d0590d2bf0c 100644 (file)
@@ -1,3 +1,20 @@
+2004-01-04  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/12226
+       * testsuite/27_io/basic_filebuf/4.cc: Remove use of invalid copy
+       constructor.
+       * testsuite/27_io/basic_fstream/4.cc: Likewise.
+       * testsuite/27_io/basic_ifstream/4.cc: Likewise.
+       * testsuite/27_io/basic_ios/4.cc: Likewise.
+       * testsuite/27_io/basic_iostream/4.cc: Likewise.
+       * testsuite/27_io/basic_istream/4.cc: Likewise.
+       * testsuite/27_io/basic_istingstream/4.cc: Likewise.
+       * testsuite/27_io/basic_ofstream/4.cc: Likewise.
+       * testsuite/27_io/basic_ostream/4.cc: Likewise.
+       * testsuite/27_io/basic_ostringstream/4.cc: Likewise.
+       * testsuite/27_io/basic_stringbuf/5.cc: Likewise.
+       * testsuite/27_io/basic_stringstream/4.cc: Likewise.
+
 2004-01-04  Paolo Carlini  <pcarlini@suse.de>
 
        * config/locale/generic/numeric_members.cc (_M_initialize_numpunct):
index e330430973c6f332949067bf9e58d9a7bfacdd13..3bde4817e27e1a511ce0e7e5c2385498f2763ca8 100644 (file)
@@ -27,7 +27,7 @@ void test01()
   // Check for required base class.
   typedef std::filebuf test_type;
   typedef std::streambuf base_type;
-  const test_type& obj = test_type();
+  const test_type& obj = *new test_type();
   const base_type* base __attribute__((unused)) = &obj;
 }
 
index cf838faab05c813aa9052e50791355b6663f37c7..58f6f99ba33bcdc2a3fd1fda485789f7565d0fca 100644 (file)
@@ -28,7 +28,7 @@ void test01()
   // Check for required base class.
   typedef std::fstream test_type;
   typedef std::iostream base_type;
-  const test_type& obj = test_type();
+  const test_type& obj = *new test_type();
   const base_type* base __attribute__((unused)) = &obj;
 }
 
index 3c6efe85d5f8389fc25eee9efddc9580227232af..3cc66cf7f1913e31fff167babb69556a900c587f 100644 (file)
@@ -28,7 +28,7 @@ void test01()
   // Check for required base class.
   typedef std::ifstream test_type;
   typedef std::istream base_type;
-  const test_type& obj = test_type();
+  const test_type& obj = *new test_type();
   const base_type* base __attribute__((unused)) = &obj;
 }
 
index 517799e861bea2860a8d88e831298bb412a11023..7e70339d87539ec92a0263a81e64aba930692e4a 100644 (file)
@@ -30,7 +30,7 @@ void test01()
   typedef std::ios_base base_type;
   
   std::stringbuf buf;
-  const test_type& obj = test_type(&buf);
+  const test_type& obj = *new test_type(&buf);
   const base_type* base __attribute__((unused)) = &obj;
 }
 
index 0c47e675162daeb374cdd45b4e3c6405b85da466..3c4a4922c580d32295c6f473b18634971d0470c0 100644 (file)
@@ -31,7 +31,7 @@ void test01()
   typedef std::ostream base_type2;
 
   std::stringbuf buf;
-  const test_type& obj = test_type(&buf);
+  const test_type& obj = *new test_type(&buf);
   const base_type1* base1 __attribute__((unused)) = &obj;
   const base_type2* base2 __attribute__((unused)) = &obj;
 }
index fe7a394691a3cf76281b4e5eb3a9dd802d3220f0..76aac6bf4f555089e326cc5845d0478787e98641 100644 (file)
@@ -30,7 +30,7 @@ void test01()
   typedef std::ios base_type;
   
   std::stringbuf buf;
-  const test_type& obj = test_type(&buf);
+  const test_type& obj = *new test_type(&buf);
   const base_type* base __attribute__((unused)) = &obj;
 }
 
index 4d212dac749906a112324e867e7e912fcde4a182..c2cc29e47394520df5c763b89aae7e05ab23835e 100644 (file)
@@ -28,7 +28,7 @@ void test01()
   // Check for required base class.
   typedef std::istringstream test_type;
   typedef std::istream base_type;
-  const test_type& obj = test_type();
+  const test_type& obj = *new test_type();
   const base_type* base __attribute__((unused)) = &obj;
 }
 
index 47d7c928f89089cfa5daeb2df77eeed02cc16761..32843325e53334af331d9d1970da36962c845e9a 100644 (file)
@@ -28,7 +28,7 @@ void test01()
   // Check for required base class.
   typedef std::ofstream test_type;
   typedef std::ostream base_type;
-  const test_type& obj = test_type();
+  const test_type& obj = *new test_type();
   const base_type* base __attribute__((unused)) = &obj;
 }
 
index c945539a3b7606a053db9c1aaf3de2f1da852d95..e9affab30de93e75aae394259ab7aec2be918544 100644 (file)
@@ -30,7 +30,7 @@ void test01()
   typedef std::ios base_type;
   
   std::stringbuf buf;
-  const test_type& obj = test_type(&buf);
+  const test_type& obj = *new test_type(&buf);
   const base_type* base __attribute__((unused)) = &obj;
 }
 
index aafd2bcd6cd5e22746d944d5d7d81e4485461b73..f687b5065ede0ad454d5a059bc0660b8bfc7fa4a 100644 (file)
@@ -28,7 +28,7 @@ void test01()
   // Check for required base class.
   typedef std::ostringstream test_type;
   typedef std::ostream base_type;
-  const test_type& obj = test_type();
+  const test_type& obj = *new test_type();
   const base_type* base __attribute__((unused)) = &obj;
 }
 
index b09e94d1a9feb1c30dbc3002e9a0aec1319e25e8..792171564cf4ca1148f0d507b6b68d1bb1625a04 100644 (file)
@@ -27,7 +27,7 @@ void test01()
   // Check for required base class.
   typedef std::stringbuf test_type;
   typedef std::streambuf base_type;
-  const test_type& obj = test_type();
+  const test_type& obj = *new test_type();
   const base_type* base __attribute__((unused)) = &obj;
 }
 
index 6189c2677847ec342992f32322eec1e468faeed1..1f210d78530a3a64de538527b119d003748db152 100644 (file)
@@ -28,7 +28,7 @@ void test01()
   // Check for required base class.
   typedef std::stringstream test_type;
   typedef std::iostream base_type;
-  const test_type& obj = test_type();
+  const test_type& obj = *new test_type();
   const base_type* base __attribute__((unused)) = &obj;
 }