foreach range construction bug?!!?!?!?

Era Scarecrow rtcvb32 at yahoo.com
Sun Jan 6 12:34:48 PST 2013


On Sunday, 6 January 2013 at 18:59:36 UTC, Phil Lavoie wrote:
> Hi all,
>
> I am very close to posting a bug report, however I would like 
> some insights first. See the code below:
>   version( Working ) {
>     //Works with both.
>     auto errors = GLErrors();
>     foreach( GLenum err; errors ) {
>       writeln( glError( err ) );
>     }
>   } else {
>     //Crashes in non defined version.
>     foreach( GLenum err; GLErrors() ) {
>       writeln( glError( err ) );
>     }
>   }


> Now here is what is really troubling me, the non defined 
> version (using the import library) crashes when the range 
> constructor is called inside the foreach statement, which is 
> weird by itself. In addition, in DOES NOT crash when the 
> functions are artificially defined. Anyone seen that before? Or 
> maybe I am doing something wrong?
>
> This is the program output when you don't define any versions:
> Number of extensions: -1
> object.Error: Access Violation
>
> Defining Working or Defined will produce an infinite loop (or 
> maybe not).


> Oh, BTW, I am aware that GL_EXTENSIONS (whose value is missing
but it's actually this: 0x1F03) is not a valid enum for the
request, I am EXPECTING an error from opengl.

  I doubt it's the constructor, as it just copies it's .init (or 
zeroizes depending on what's better). The segfault would be from 
the first call of .empty .

  Now this is a few shots in the dark and going from memory, but 
as I recall compiled code (but not linked) won't have any calls 
actually go where they are suppose to; The linker resolves that 
during the linking step. So either those addresses aren't getting 
linked and resolved when it gets compiled, or your opengl32.lib 
is trying to call something that doesn't exist thereby throwing 
SegFault.

  Is the lib compiled with the same compiler (set) as your current 
source (gdc/gcc for example)? Since it's not a dll (or .so file), 
perhaps something incompatible is going on in the background.

  Another thought as I write is are you using gnu/linux? If you 
are, are you using Xwindows (probably...)? Xwindows as I recall 
is server/daemon based so if the service(s) aren't running 
perhaps the openGL driver/service may not even be active, or 
requires root access to connect to it.


More information about the Digitalmars-d-learn mailing list