[odb-users] Bug: Schema catalog registration not initialized in Visual Studio 2012 RC

Philippe Cadieux-Pelletier philly.dilly at gmail.com
Thu Jun 14 10:29:09 EDT 2012


Hi Boris,
The code is generated in the same file. The generated code and the code
that uses it is in the same project put it is a lib. Haven't tried it on
vc10 since I don't have it installed on this machine.

On Thu, Jun 14, 2012 at 10:02 PM, Boris Kolpackov
<boris at codesynthesis.com>wrote:

> Hi Philippe,
>
> Philippe Cadieux-Pelletier <philly.dilly at gmail.com> writes:
>
> > Just a heads up that I found a bug where it appears the static
> > schema_catalog_entry variables do not get initialized (and therefore
> > registered) prior to calling schema_catalog::create_schema. The current
> > workaround I have is to not compile the generated cxx but rather include
> it
> > in the same cpp file that calls schema_catalog::create_schema so that
> they
> > are in the same compilation unit.
>
> This is very strange. Are you generating the schema creation code into
> a separate file (i.e., using the '--schema-format separate' option) or
> is it in the same source file as the rest of the generated code?
>
> The only situation that I know can lead to this behavior is if you
> generate the -schema.cxx file, package its object code into a static
> library (.lib or .a), and then link this library into your executable.
> In this case, because your application doesn't link to any of the
> symbols from the -schema.cxx file directly, linker will not add it
> to the executable.
>
> > I'm not sure if the VC11 compiler now lazily initializes global
> > variables on a per compilation unit basis or if it's the linker
> > that stripped those globals since they aren't unreferenced.
>
> The lazy initialization would not be allowed by the standard since
> it has side-effects. Also the fact that including the generated source
> file into another source file fixes the problem suggests that something
> else is going on. BTW, have you tried the same code with VC10?
>
> Boris
>


More information about the odb-users mailing list