develooper Front page | perl.perl5.porters | Postings from May 2015

Re: FILE structure internals issue building blead onWindowswithVisual Studio 2015 RC

Thread Previous
From:
A. Sinan Unur
Date:
May 5, 2015 11:36
Subject:
Re: FILE structure internals issue building blead onWindowswithVisual Studio 2015 RC
Message ID:
CABbccAMqW1CJeWFg1kxNAtzWNMOuugGmjVoCBoXV9nCzLR4msQ@mail.gmail.com
On Mon, May 4, 2015 at 8:44 PM, A. Sinan Unur <nanis@cpan.org> wrote:
> On Mon, May 4, 2015 at 2:10 PM, bulk88 <bulk88@hotmail.com> wrote:
>> A. Sinan Unur wrote:
> ...
>>> As for the problem in sv.c, removing the leading + sign from a certain
>>> field fixes the issue. I do not know if the + sign is needed for other
>>> environments.
...
>> That is clearly a compiler bug, since it isn't broken on VC 2013

I just submitted Microsoft a bug report for this. See:
<https://connect.microsoft.com/VisualStudio/feedback/details/1304939>

If you do have a Microsoft ID, it *might* be useful to vote for it ;-)

--- bug report ---

Consider the following simple C program:

#include <stddef.h>
#include <stdio.h>

struct x {
    int y;
    char z;
};

static const size_t i = +offsetof(struct x, z);

int main(void) {
    printf("MSCVER: %d\n", _MSC_VER);
    return 0;
}

Compiling with VS2013CE command line tools:

C:\...\Temp> cl t.c

Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

t.c

Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:t.exe
t.obj

C:\...\Temp> t.exe
MSCVER: 1800


Now, try the VS2015RC-CE tools:

C:\...\Temp> cl t.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.22816 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

t.c
t.c(9): error C2099: initializer is not a constant

Now, consider a simple change:

static const size_t i = 42+offsetof(struct x, z);

This causes the VS2015RC-CE tools to compile without problems:

C:\...\Temp> cl t.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.22816 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

t.c
Microsoft (R) Incremental Linker Version 14.00.22816.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:t.exe
t.obj

C:\...\Temp> t.exe
MSCVER: 1900

Clearly,

+offsetof(struct x, z);

is equivalent to 0+offsetof(struct x, z), and, as such is just as
constant an expression as 42+offsetof(struct x, z) and should compile
as such.

I encountered this bug while trying to build Perl using VS2015RC
tools. It prevents sv.c from compiling.

Thank you for making the Community Editions of Visual Studio tools
available, and thank you for your consideration of this bug report.

-- A. Sinan Unur

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About