[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-stdcxx-dev
Subject:    Re: [PATCH] to run configuration tests with VC7.1
From:       Martin Sebor <sebor () roguewave ! com>
Date:       2005-10-24 20:03:14
Message-ID: 435D3E02.3020901 () roguewave ! com
[Download RAW message or body]

[...]
> First part of patches is for STDCXX-15 bug. Strange that they are not in
> SVN.

Whoops, I missed this. Thanks for the patch. I have a few comments,
questions:

> -------------------------------------------------------------------------------------------------------- \
>  
> 
> Index: D:/stdcxx/etc/config/src/BAD_CAST_DTOR.cpp
> ===================================================================
> --- D:/stdcxx/etc/config/src/BAD_CAST_DTOR.cpp (revision 312643)
> +++ D:/stdcxx/etc/config/src/BAD_CAST_DTOR.cpp (working copy)
> @@ -76,6 +76,8 @@
> int main (int argc, char *argv[])
> {
> (void)&argv;
> +    if (argc < 0xFFF)
> +       return 0;
> 
> // try to prevent the compiler from optimizing the dtor call away
> std::bad_cast *ptr = argc > 1 ? new Derived : new std::bad_cast;
> @@ -83,7 +85,7 @@
> delete ptr;
> 
> // link only test
> -    return 0;
> +    return 1;

I don't see why this is necessary.

> }
> 
> Derived::~Derived () { }
> 
> Index: D:/stdcxx/etc/config/src/BAD_TYPEID_DTOR.cpp
> ===================================================================
> --- D:/stdcxx/etc/config/src/BAD_TYPEID_DTOR.cpp (revision 312643)
> +++ D:/stdcxx/etc/config/src/BAD_TYPEID_DTOR.cpp (working copy)
> @@ -76,14 +76,15 @@
> int main (int argc, char *argv[])
> {
> (void)&argv;
> +    if (argc < 0x0FFF)
> +       return 0;
> 
> // try to prevent the compiler from optimizing the dtor call away
> std::bad_typeid *ptr = argc > 1 ? new Derived : new std::bad_typeid;
> -
> delete ptr;
> 
> // link only test
> -    return 0;
> +    return 1;

Same here.

> }
> 
> Derived::~Derived () { }
> 
> Index: D:/stdcxx/etc/config/src/EXCEPTION_DTOR.cpp
> ===================================================================
> --- D:/stdcxx/etc/config/src/EXCEPTION_DTOR.cpp (revision 312643)
> +++ D:/stdcxx/etc/config/src/EXCEPTION_DTOR.cpp (working copy)
> @@ -81,18 +81,17 @@
> {
> (void)&argv;
> 
> -    // use dynamic allocation to prevent the compiler
> -    // from optimizing the dtor call away
> -    std::exception *ptr = 0;
> +    // try to prevent the compiler from optimizing the dtor call away
> +    std::exception *ptr;
> 
> -    if (2 < argc)
> +    if (argc < 0x0FFF) //just a trick to force compiler to leave exception
> .dtor but never allow it to exceute
> +    {
> +       return 0;
> +    }
> +    //since test is executed without arguments we should never get there
> ptr = new Derived;
> -    else if (1 < argc)
> -        ptr = new std::exception;
> -
> delete ptr;
> -
> -    return !(2 < argc ? 1 == dtor : 0 == dtor);
> +    return 1;

Same here.

> }
> 
> Derived::~Derived () { ++dtor; }
> 
> ---------------------------------------------------------------------------------------------------- \
>  
> 
> Second part is to allow building of .lib.cpp files into shared libraries.
> 
> ---------------------------------------------------------------------------------------------------- \
>  
> Index: D:/stdcxx/etc/config/src/collapse_static_locals.lib.cpp
> ===================================================================
> --- D:/stdcxx/etc/config/src/collapse_static_locals.lib.cpp (revision
> 312643)
> +++ D:/stdcxx/etc/config/src/collapse_static_locals.lib.cpp (working copy)
> @@ -1,6 +1,10 @@
> +// also defined in COLLAPSE_STATIC_LOCALS.cpp
> 
> +// include _RWSTD_EXPORT definition
> +#include <rw/_defs.h>

Hmmm, I'm not sure about this trick. <rw/_defs.h> doesn't expect
to be included during configuration.

> +
> // also defined in COLLAPSE_STATIC_LOCALS.cpp
> -inline int foo ()
> +_RWSTD_EXPORT inline int foo ()

I think a safer way to do this is to simply hardcode the
__declspec(dllexport) bit in there for MSVC.

> {
> // multiple instances of `i' must be collapsed
> static int i = 0;
> @@ -8,7 +12,7 @@
> }
> 
> // bar() returns foo()
> -int bar ()
> +_RWSTD_EXPORT int bar ()
> {
> return foo ();
> }
> 
> 
> Index: D:/stdcxx/etc/config/src/collapse_template_locals.lib.cpp
> ===================================================================
> --- D:/stdcxx/etc/config/src/collapse_template_locals.lib.cpp (revision
> 312643)
> +++ D:/stdcxx/etc/config/src/collapse_template_locals.lib.cpp (working 
> copy)
> @@ -1,7 +1,11 @@
> +// also defined in COLLAPSE_TEMPLATE_STATICS.cpp
> 
> +// include _RWSTD_EXPORT definition
> +#include <rw/_defs.h>
> +
> // also defined in COLLAPSE_TEMPLATE_STATICS.cpp
> template <class T>
> -T foo (T)
> +_RWSTD_EXPORT T foo (T)

Same here, although I'm not sure the __declspec thing works on
templates (IIRC, MSVC 6 complained about it).

> {
> // multiple instances of `t' must be collapsed
> static T t;
> @@ -10,7 +14,7 @@
> 
> 
> // bar() returns foo()
> -int bar ()
> +_RWSTD_EXPORT int bar ()
> {
> return foo (0);
> }
> 
> 
> Index: D:/stdcxx/etc/config/src/collapse_template_statics.lib.cpp
> ===================================================================
> --- D:/stdcxx/etc/config/src/collapse_template_statics.lib.cpp (revision
> 312643)
> +++ D:/stdcxx/etc/config/src/collapse_template_statics.lib.cpp (working
> copy)
> @@ -1,4 +1,8 @@
> +// also defined in COLLAPSE_TEMPLATE_STATICS.cpp
> 
> +// include _RWSTD_EXPORT definition
> +#include <rw/_defs.h>
> +
> // also defined in COLLAPSE_TEMPLATE_STATICS.cpp
> template <class T>
> struct S
> @@ -11,7 +15,7 @@
> T S<T>::t;
> 
> 
> -int bar ()
> +_RWSTD_EXPORT int bar ()
> {

Same here.

> // S<int>::t instantiated and modified in 
> COLLAPSE_TEMPLATE_STATICS.cpp
> return S<int>::t++;
> 
> Index: D:/stdcxx/etc/config/src/extern_inline.lib.cpp
> ===================================================================
> --- D:/stdcxx/etc/config/src/extern_inline.lib.cpp (revision 312643)
> +++ D:/stdcxx/etc/config/src/extern_inline.lib.cpp (working copy)
> @@ -1,14 +1,17 @@
> 
> -extern inline int foo (int i)
> +// include _RWSTD_EXPORT definition
> +#include <rw/_defs.h>
> +
> +_RWSTD_EXPORT extern inline int foo (int i)
> {

Same as above.

> return i + 1;
> }
> 
> -extern int bar (int i)
> +_RWSTD_EXPORT extern int bar (int i)
> {

Ditto.

> return i + 1;
> }
> 
> // take the address of the inline above to prevent
> // it from being optimized away
> -extern int (*volatile pf)(int) = foo;
> +_RWSTD_EXPORT extern int (*volatile pf)(int) = foo;
> 
> Index: D:/stdcxx/etc/config/src/lib_exceptions.lib.cpp
> ===================================================================
> --- D:/stdcxx/etc/config/src/lib_exceptions.lib.cpp (revision 312643)
> +++ D:/stdcxx/etc/config/src/lib_exceptions.lib.cpp (working copy)
> @@ -1,7 +1,8 @@
> 
> -#include "config.h"
> +// include _RWSTD_EXPORT definition
> +#include <rw/_defs.h>
> 
> -int foo (int i)
> +_RWSTD_EXPORT int foo (int i)
> {

Ditto.

> if (i)
> throw i;

Martin


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic