Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VC6 has missing ')'s on macro expansion, cBOOL and U8, Unicode.xs #13697

Closed
p5pRT opened this issue Apr 1, 2014 · 17 comments
Closed

VC6 has missing ')'s on macro expansion, cBOOL and U8, Unicode.xs #13697

p5pRT opened this issue Apr 1, 2014 · 17 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 1, 2014

Migrated from rt.perl.org#121554 (status was 'resolved')

Searchable as RT121554$

@p5pRT
Copy link
Author

p5pRT commented Apr 1, 2014

From @bulk88

Created by @bulk88

jdb on #p5p complained today that compiling blead with VC6 gave (from
his build)

---------------------------------------------------------------
  cl -c -I../Encode -nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONS
  OLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_
  SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T -O1 -MD -Zi -DNDEBUG
-DVERSION=\"2.09\"
  -DXS_VERSION=\"2.09\" "-I..\..\..\lib\CORE" Unicode.c
  Unicode.c
  Unicode.xs(293) : error C2143​: syntax error : missing ')' before '>'
  Unicode.xs(293) : error C2143​: syntax error : missing ')' before ';'
  Unicode.xs(393) : error C2143​: syntax error : missing ')' before '>'
  Unicode.xs(393) : error C2143​: syntax error : missing ')' before ';'
  NMAKE : fatal error U1077​: 'cl' : return code '0x2'
  Stop.
  NMAKE : fatal error U1077​: 'W​:\psdk\bin\nmake.exe' : return code '0x2'
  Stop.
  Unsuccessful make(cpan/Encode)​: code=512 at ..\make_ext.pl line 561.
  NMAKE : fatal error U1077​: '..\miniperl.exe' : return code '0x2'
  Stop.
-------------------------------------------------

I got the same thing with VC6. There are missing )s in the Move macro
expansion.

  ((void)
  ((((sizeof
  (U8 > 1 && ((size_t) (e - s) + 0.0) > ((size_t)
~ 0) / sizeof(U8)
  && (S_croak_memory_wrap(), 0)) ? (char) 1 :
(char) 0),
  (void) memmove((char *) (((str)->sv_u.svu_pv)),
(const char *) (s),
  (e - s) * sizeof(U8)));

Encode-Unicode has strange line called "#define U8 U8" which is from
2002
http​://perl5.git.perl.org/perl.git/commit/6d1c0808b641926567cd16e07679f427c5fedc61?f=cpan/Encode/Unicode/Unicode.xs

I cut the bug down into the attached uni3.c.

On VC6.
---------------------------------------------------------
C​:\perl519\src\cpan\Encode\Unicode>cl
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

usage​: cl [ option... ] filename... [ /link linkoption... ]

C​:\perl519\src\cpan\Encode\Unicode>type uni3.c
#define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
#define EXPECT(expr,val) (expr)
#define UNLIKELY(cond) EXPECT(cBOOL(cond),FALSE)
#define MEM_WRAP_CHECK(n,t) \
  (void)(UNLIKELY(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) >
MEM_SIZE_MAX/size
of(t)) && (croak_memory_wrap(),0))
#define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
#define Move(s,d,n,t) (MEM_WRAP_CHECK_(n,t)
(void)memmove((char*)(d),(const ch
ar*)(s), (n) * sizeof(t)))
#define U8 U8

Move(source,dest,len,U8);
// U8 or cBOOL alone, or both off, don't cause missing )s, only U8 and
cBOOL tog
ether cause missing )s

C​:\perl519\src\cpan\Encode\Unicode>cl -P Uni3.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Uni3.c

C​:\perl519\src\cpan\Encode\Unicode>type uni3.i
#line 1 "Uni3.c"

((void)((((sizeof(U8> 1 && ((MEM_SIZE)(len)+0.0) >
MEM_SIZE_MAX/sizeof(U8) && (c
roak_memory_wrap(),0)) ? (bool)1 : (bool)0),
(void)memmove((char*)(dest),(const
char*)(source), (len) * sizeof(U8)));

C​:\perl519\src\cpan\Encode\Unicode>type uni3.c
#define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
#define EXPECT(expr,val) (expr)
#define UNLIKELY(cond) EXPECT(cBOOL(cond),FALSE)
#define MEM_WRAP_CHECK(n,t) \
  (void)(UNLIKELY(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) >
MEM_SIZE_MAX/size
of(t)) && (croak_memory_wrap(),0))
#define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
#define Move(s,d,n,t) (MEM_WRAP_CHECK_(n,t)
(void)memmove((char*)(d),(const ch
ar*)(s), (n) * sizeof(t)))
//#define U8 U8

Move(source,dest,len,U8);
// U8 or cBOOL alone, or both off, don't cause missing )s, only U8 and
cBOOL tog
ether cause missing )s

C​:\perl519\src\cpan\Encode\Unicode>cl -P Uni3.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Uni3.c

C​:\perl519\src\cpan\Encode\Unicode>type uni3.i
#line 1 "Uni3.c"

((void)((((sizeof(U8) > 1 && ((MEM_SIZE)(len)+0.0) >
MEM_SIZE_MAX/sizeof(U8)) ?
(bool)1 : (bool)0)) && (croak_memory_wrap(),0)),
(void)memmove((char*)(dest),(co
nst char*)(source), (len) * sizeof(U8)));

C​:\perl519\src\cpan\Encode\Unicode>type uni3.c
//#define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
#define EXPECT(expr,val) (expr)
#define UNLIKELY(cond) EXPECT(cBOOL(cond),FALSE)
#define MEM_WRAP_CHECK(n,t) \
  (void)(UNLIKELY(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) >
MEM_SIZE_MAX/size
of(t)) && (croak_memory_wrap(),0))
#define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
#define Move(s,d,n,t) (MEM_WRAP_CHECK_(n,t)
(void)memmove((char*)(d),(const ch
ar*)(s), (n) * sizeof(t)))
#define U8 U8

Move(source,dest,len,U8);
// U8 or cBOOL alone, or both off, don't cause missing )s, only U8 and
cBOOL tog
ether cause missing )s

C​:\perl519\src\cpan\Encode\Unicode>cl -P Uni3.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Uni3.c

C​:\perl519\src\cpan\Encode\Unicode>type uni3.i
#line 1 "Uni3.c"

((void)((cBOOL(sizeof(U8) > 1 && ((MEM_SIZE)(len)+0.0) >
MEM_SIZE_MAX/sizeof(U8)
)) && (croak_memory_wrap(),0)), (void)memmove((char*)(dest),(const
char*)(source
), (len) * sizeof(U8)));

C​:\perl519\src\cpan\Encode\Unicode>
----------------------------------------------------------------------------

VC7/VC 2003 are fine.

----------------------------------------------------------------------------

C​:\perl519\src\cpan\Encode\Unicode>cl
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

usage​: cl [ option... ] filename... [ /link linkoption... ]

C​:\perl519\src\cpan\Encode\Unicode>type uni3.c
#define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
#define EXPECT(expr,val) (expr)
#define UNLIKELY(cond) EXPECT(cBOOL(cond),FALSE)
#define MEM_WRAP_CHECK(n,t) \
  (void)(UNLIKELY(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) >
MEM_SIZE_MAX/size
of(t)) && (croak_memory_wrap(),0))
#define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
#define Move(s,d,n,t) (MEM_WRAP_CHECK_(n,t)
(void)memmove((char*)(d),(const ch
ar*)(s), (n) * sizeof(t)))
#define U8 U8

Move(source,dest,len,U8);
// U8 or cBOOL alone, or both off, don't cause missing )s, only U8 and
cBOOL tog
ether cause missing )s

C​:\perl519\src\cpan\Encode\Unicode>cl -P uni3.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

uni3.c

C​:\perl519\src\cpan\Encode\Unicode>type uni3.i
#line 1 "uni3.c"

((void)((((sizeof(U8) > 1 && ((MEM_SIZE)(len)+0.0) >
MEM_SIZE_MAX/sizeof(U8)) ?
(bool)1 : (bool)0)) && (croak_memory_wrap(),0)),
(void)memmove((char*)(dest),(co
nst char*)(source), (len) * sizeof(U8)));

C​:\perl519\src\cpan\Encode\Unicode>
----------------------------------------------------------------------------------

This sounds like something bisectable because I built VC6 builds a
couple months ago without problems.

Changing "#define U8 U8" to "#define U8 U81" fixes the bug.

IDK if this is related
http​://connect.microsoft.com/VisualStudio/feedback/details/318940/macro-expansion-bug
, I tested VC7 and VC6 with that bug, both produced the same code.

Anyone have tweaks/permutations to the sample uni3.c file for me to try
to better narrow down the bugs behavior?

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.19.10:

Configured by Owner at Sat Mar 15 22:30:42 2014.

Summary of my perl5 (revision 5 version 19 subversion 10) configuration:
  Derived from: 2179658b5e799a6e3c4e736ec7c84b0f50bf3473
  Ancestor: e9251c1a8f4944e6dceff5240d9e109ba075ff29
  Platform:
    osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -G7 -GL 
-DWIN32 -D_CONSOLE -DNO_STRICT  -DPERL_TEXTMODE_SCRIPTS 
-DPERL_HASH_FUNC_ONE_AT_A_TIME -DPERL_IMPLICIT_CONTEXT 
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T',
    optimize='-O1 -MD -Zi -DNDEBUG -G7 -GL',
    cppflags='-DWIN32'
    ccversion='13.10.6030', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', 
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf 
-ltcg  -libpath:"c:\perl519\lib\CORE"  -machine:x86'
    libpth="C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\lib"
    libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib 
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
    perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib 
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  
version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl519.lib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug 
-opt:ref,icf -ltcg  -libpath:"c:\perl519\lib\CORE"  -machine:x86'

Locally applied patches:
    uncommitted-changes
    2179658b5e799a6e3c4e736ec7c84b0f50bf3473


@INC for perl 5.19.10:
    C:/perl519/site/lib
    C:/perl519/lib
    .


Environment for perl 5.19.10:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\perl519\bin;C:\Program Files\Microsoft Visual Studio .NET 
2003\Common7\IDE;C:\Program Files\Microsoft Visual Studio .NET 
2003\VC7\BIN;C:\Program Files\Microsoft Visual Studio .NET 
2003\Common7\Tools;C:\Program Files\Microsoft Visual Studio .NET 
2003\Common7\Tools\bin\prerelease;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;
    PERL_BADLANG (unset)
    SHELL (unset)


@p5pRT
Copy link
Author

p5pRT commented Apr 1, 2014

From @bulk88

#define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
#define EXPECT(expr,val) (expr)
#define UNLIKELY(cond) EXPECT(cBOOL(cond),FALSE)
#define MEM_WRAP_CHECK(n,t) \
  (void)(UNLIKELY(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) > MEM_SIZE_MAX/sizeof(t)) && (croak_memory_wrap(),0))
#define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
#define Move(s,d,n,t) (MEM_WRAP_CHECK_(n,t) (void)memmove((char*)(d),(const char*)(s), (n) * sizeof(t)))
#define U8 U8

Move(source,dest,len,U8);
// U8 or cBOOL alone, or both off, don't cause missing )s, only U8 and cBOOL together cause missing )s

@p5pRT
Copy link
Author

p5pRT commented Apr 1, 2014

From @steve-m-hay

On 1 April 2014 05​:02, bulk88 <perlbug-followup@​perl.org> wrote​:

# New Ticket Created by bulk88
# Please include the string​: [perl #121554]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121554 >

This is a bug report for perl from bulk88@​hotmail.com,
generated with the help of perlbug 1.40 running under perl 5.19.10.

-----------------------------------------------------------------
[Please describe your issue here]

jdb on #p5p complained today that compiling blead with VC6 gave (from
his build)

---------------------------------------------------------------
cl -c -I../Encode -nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -DWIN32 -D_CONS
OLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_
SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T -O1 -MD -Zi -DNDEBUG
-DVERSION=\"2.09\"
-DXS_VERSION=\"2.09\" "-I..\..\..\lib\CORE" Unicode.c
Unicode.c
Unicode.xs(293) : error C2143​: syntax error : missing ')' before '>'
Unicode.xs(293) : error C2143​: syntax error : missing ')' before ';'
Unicode.xs(393) : error C2143​: syntax error : missing ')' before '>'
Unicode.xs(393) : error C2143​: syntax error : missing ')' before ';'
NMAKE : fatal error U1077​: 'cl' : return code '0x2'
Stop.
NMAKE : fatal error U1077​: 'W​:\psdk\bin\nmake.exe' : return code '0x2'
Stop.
Unsuccessful make(cpan/Encode)​: code=512 at ..\make_ext.pl line 561.
NMAKE : fatal error U1077​: '..\miniperl.exe' : return code '0x2'
Stop.
-------------------------------------------------

[...]

This sounds like something bisectable because I built VC6 builds a
couple months ago without problems.

Bisected to​:

5d9574c (davem)​:
sprinkle LIKELY() on pp_hot.c scope.c and some *.h

Adding this to the blockers list...

@p5pRT
Copy link
Author

p5pRT commented Apr 1, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Apr 1, 2014

From @bulk88

On Tue Apr 01 01​:12​:48 2014, shay wrote​:

On 1 April 2014 05​:02, bulk88 <perlbug-followup@​perl.org> wrote​:

This sounds like something bisectable because I built VC6 builds a
couple months ago without problems.

Bisected to​:

5d9574c (davem)​:
sprinkle LIKELY() on pp_hot.c scope.c and some *.h

Adding this to the blockers list...

Some more testing. Removal of parens on EXPECT. VC6


C​:\perl519\src\cpan\Encode\Unicode>cl
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

usage​: cl [ option... ] filename... [ /link linkoption... ]

C​:\perl519\src\cpan\Encode\Unicode>type uni3.c
#define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
#define EXPECT(expr,val) expr
#define UNLIKELY(cond) EXPECT(cBOOL(cond),FALSE)
#define MEM_WRAP_CHECK(n,t) \
  (void)(UNLIKELY(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) > MEM_SIZE_MAX/size
of(t)) && (croak_memory_wrap(),0))
#define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
#define Move(s,d,n,t) (MEM_WRAP_CHECK_(n,t) (void)memmove((char*)(d),(const ch
ar*)(s), (n) * sizeof(t)))
#define U8 U8

Move(source,dest,len,U8);
// U8 or cBOOL alone, or both off, don't cause missing )s, only U8 and cBOOL tog
ether cause missing )s

C​:\perl519\src\cpan\Encode\Unicode>cl -P uni3.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

uni3.c
uni3.c(10) : fatal error C1057​: unexpected end of file in macro expansion

C​:\perl519\src\cpan\Encode\Unicode>type uni3.i
#line 1 "uni3.c"

((void)(

C​:\perl519\src\cpan\Encode\Unicode>


VC 2003


C​:\perl519\src\cpan\Encode\Unicode>cl
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

usage​: cl [ option... ] filename... [ /link linkoption... ]

C​:\perl519\src\cpan\Encode\Unicode>type uni3.c
#define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0)
#define EXPECT(expr,val) expr
#define UNLIKELY(cond) EXPECT(cBOOL(cond),FALSE)
#define MEM_WRAP_CHECK(n,t) \
  (void)(UNLIKELY(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) > MEM_SIZE_MAX/size
of(t)) && (croak_memory_wrap(),0))
#define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
#define Move(s,d,n,t) (MEM_WRAP_CHECK_(n,t) (void)memmove((char*)(d),(const ch
ar*)(s), (n) * sizeof(t)))
#define U8 U8

Move(source,dest,len,U8);
// U8 or cBOOL alone, or both off, don't cause missing )s, only U8 and cBOOL tog
ether cause missing )s

C​:\perl519\src\cpan\Encode\Unicode>cl -P uni3.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

uni3.c

C​:\perl519\src\cpan\Encode\Unicode>type uni3.i
#line 1 "uni3.c"

((void)(((sizeof(U8) > 1 && ((MEM_SIZE)(len)+0.0) > MEM_SIZE_MAX/sizeof(U8)) ? (
bool)1 : (bool)0) && (croak_memory_wrap(),0)), (void)memmove((char*)(dest),(cons
t char*)(source), (len) * sizeof(U8)));

C​:\perl519\src\cpan\Encode\Unicode>


Distilled even more


C​:\perl519\src\cpan\Encode\Unicode>cl
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

usage​: cl [ option... ] filename... [ /link linkoption... ]

C​:\perl519\src\cpan\Encode\Unicode>type uni3.c
#define cBOOL(cbool) cbool
#define EXPECT(expr) expr
#define UNLIKELY(cond) EXPECT(cBOOL(cond))
#define MEM_WRAP_CHECK(n,t) UNLIKELY(sizeof(t) FFFF)
#define U8 U8

MEM_WRAP_CHECK(len, U8);

C​:\perl519\src\cpan\Encode\Unicode>cl -P uni3.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

uni3.c
uni3.c(7) : fatal error C1057​: unexpected end of file in macro expansion

C​:\perl519\src\cpan\Encode\Unicode>type uni3.c
#define cBOOL(cbool) cbool
#define EXPECT(expr) (expr)
#define UNLIKELY(cond) EXPECT(cBOOL(cond))
#define MEM_WRAP_CHECK(n,t) UNLIKELY(sizeof(t) FFFF)
#define U8 U8

MEM_WRAP_CHECK(len, U8);

C​:\perl519\src\cpan\Encode\Unicode>cl -P uni3.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

uni3.c

C​:\perl519\src\cpan\Encode\Unicode>type uni3.i
#line 1 "uni3.c"

(sizeof(U8FFFF);

C​:\perl519\src\cpan\Encode\Unicode>


Notice the missing ) and missing space after "U8" in the expansion. Removing/commenting out cBOOL stops the error.

--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Apr 1, 2014

From @bulk88

The swallowed )s can be fixed by adding more )s. (you could also remove the #define U8 U8, but that isn't interesting to explore since I documented it in the OP)


C​:\perl519\src\cpan\Encode\Unicode>cl
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

usage​: cl [ option... ] filename... [ /link linkoption... ]

C​:\perl519\src\cpan\Encode\Unicode>type uni3.c
#define cBOOL(cbool) cbool
#define EXPECT(expr) (expr)
#define UNLIKELY(cond) EXPECT(cBOOL(cond))
#define MEM_WRAP_CHECK(n,t) UNLIKELY(sizeof(t) )) FFFF)
#define U8 U8

MEM_WRAP_CHECK(len, U8);

C​:\perl519\src\cpan\Encode\Unicode>cl -P uni3.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

uni3.c

C​:\perl519\src\cpan\Encode\Unicode>type uni3.i
#line 1 "uni3.c"

(sizeof(U8) FFFF);

C​:\perl519\src\cpan\Encode\Unicode>


C​:\perl519\src\cpan\Encode\Unicode>cl
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

usage​: cl [ option... ] filename... [ /link linkoption... ]

C​:\perl519\src\cpan\Encode\Unicode>type uni3.c
#define cBOOL(cbool) cbool
#define EXPECT(expr) (expr)
#define UNLIKELY(cond) EXPECT(cBOOL(cond))
#define MEM_WRAP_CHECK(n,t) UNLIKELY(sizeof(t) )) FFFF)
#define U8 U8

MEM_WRAP_CHECK(len, U8);

C​:\perl519\src\cpan\Encode\Unicode>cl -P uni3.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.6030 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

uni3.c

C​:\perl519\src\cpan\Encode\Unicode>type uni3.i
#line 1 "uni3.c"

(sizeof(U8))) FFFF);

C​:\perl519\src\cpan\Encode\Unicode>


--
bulk88 ~ bulk88 at hotmail.com

@p5pRT
Copy link
Author

p5pRT commented Apr 8, 2014

From @steve-m-hay

(For the record, further discussion has appeared on p5p, including a working solution given here​: http​://www.nntp.perl.org/group/perl.perl5.porters/2014/04/msg214289.html)

@p5pRT
Copy link
Author

p5pRT commented Apr 8, 2014

From [Unknown Contact. See original ticket]

(For the record, further discussion has appeared on p5p, including a working solution given here​: http​://www.nntp.perl.org/group/perl.perl5.porters/2014/04/msg214289.html)

@p5pRT
Copy link
Author

p5pRT commented Apr 28, 2014

From @steve-m-hay

Now fixed in blead by commit 080a704 using Dan's modified version of Daniel's patch.

Thanks to both (and to Jan for reporting it).

@p5pRT
Copy link
Author

p5pRT commented Apr 28, 2014

@steve-m-hay - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Apr 28, 2014
@p5pRT
Copy link
Author

p5pRT commented Apr 28, 2014

From @iabyn

On Mon, Apr 28, 2014 at 10​:20​:52AM -0700, Steve Hay via RT wrote​:

Now fixed in blead by commit 080a704 using Dan's modified version of Daniel's patch.

Thanks to both (and to Jan for reporting it).

Unfortunately that's broken g++ builds.

Encode/encode.h contains​:

  #ifdef U8
  /* See comment at top of file for deviousness */

  extern int do_encode(const encpage_t *enc, const U8 *src, STRLEN *slen,
  U8 *dst, STRLEN dlen, STRLEN *dout, int approx,
  const U8 *term, STRLEN tlen);

  extern void Encode_DefineEncoding(encode_t *enc);

  #endif /* U8 */

and U8 is apparently no longer defined(?), so do_encode() isn't getting
declared, so the build fails with​:

g++ -c -I./Encode -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -ggdb -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -DVERSION=\"2.57\" -DXS_VERSION=\"2.57\" -fPIC "-I../.." Encode.c
Encode.xs​: In function ‘SV* encode_method(PerlInterpreter*, const encode_t*, const encpage_t*, SV*, int, STRLEN*, SV*, int*, SV*)’​:
Encode.xs​:131​:29​: error​: ‘do_encode’ was not declared in this scope
  trm, trmlen)) )
  ^

I have no idea what the correct fix is.

--
You're only as old as you look.

@p5pRT
Copy link
Author

p5pRT commented Apr 28, 2014

From @jandubois

I'm not in a position to test this right now, but from looking at the
code, I think this is going on​:

* The encode.h header is included by other C apps in the distribution,
so the #ifndef U8 check tried to prevent these utility apps to link
against libperl.so.

* At some point core Perl no longer used a #define for U8, but a
typedef. To compensate Encode.xs and Decode.xs added a #define U8 U8,
just to signal to encode.h that this time it it going to link against
libperl.so.

I think the proper fix would be to use e.g. the PERL_H symbol instead
of U8 to signal that you are compiling the XS code. And then you can
get rid of the #define U8 U8 completely.

Cheers,
-Jan

On Mon, Apr 28, 2014 at 4​:03 PM, Dave Mitchell <davem@​iabyn.com> wrote​:

On Mon, Apr 28, 2014 at 10​:20​:52AM -0700, Steve Hay via RT wrote​:

Now fixed in blead by commit 080a704 using Dan's modified version of Daniel's patch.

Thanks to both (and to Jan for reporting it).

Unfortunately that's broken g++ builds.

Encode/encode.h contains​:

\#ifdef U8
/\* See comment at top of file for deviousness \*/

extern int do\_encode\(const encpage\_t \*enc\, const U8 \*src\, STRLEN \*slen\,
                     U8 \*dst\, STRLEN dlen\, STRLEN \*dout\, int approx\,
             const U8 \*term\, STRLEN tlen\);

extern void Encode\_DefineEncoding\(encode\_t \*enc\);

\#endif /\* U8 \*/

and U8 is apparently no longer defined(?), so do_encode() isn't getting
declared, so the build fails with​:

g++ -c -I./Encode -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -ggdb -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -DVERSION=\"2.57\" -DXS_VERSION=\"2.57\" -fPIC "-I../.." Encode.c
Encode.xs​: In function 'SV* encode_method(PerlInterpreter*, const encode_t*, const encpage_t*, SV*, int, STRLEN*, SV*, int*, SV*)'​:
Encode.xs​:131​:29​: error​: 'do_encode' was not declared in this scope
trm, trmlen)) )
^

I have no idea what the correct fix is.

--
You're only as old as you look.

@p5pRT
Copy link
Author

p5pRT commented Apr 29, 2014

From @steve-m-hay

Apologies for the g++ breakage. Compiling as C++ on Windows isn't easy
right now. (I looked at enabling a C++ build a while back but run into
some troubles [1], which I really must try to get round to resolving
after 5.20 is out.)

Anyway, if I understand Jan's comments correctly the proposal is to try this​:

Inline Patch
diff --git a/cpan/Encode/Encode/encode.h b/cpan/Encode/Encode/encode.h
index af34ba2..52f54f7 100644
--- a/cpan/Encode/Encode/encode.h
+++ b/cpan/Encode/Encode/encode.h
@@ -1,7 +1,7 @@
 #ifndef ENCODE_H
 #define ENCODE_H

-#if !defined(U8) && !defined(U8TYPE)
+#ifndef PERL_H
 /*
    A tad devious this:
    perl normally has a #define for U8 - if that isn't present then we

That works for me (i.e. the VC6 build is still ok). Does it fix the g++ build?

[1] Blimey! It was a year and a half ago already!​:
http​://www.nntp.perl.org/group/perl.perl5.porters/2012/10/msg193978.html

On 29 April 2014 00​:46, Jan Dubois <jand@​activestate.com> wrote​:

I'm not in a position to test this right now, but from looking at the
code, I think this is going on​:

* The encode.h header is included by other C apps in the distribution,
so the #ifndef U8 check tried to prevent these utility apps to link
against libperl.so.

* At some point core Perl no longer used a #define for U8, but a
typedef. To compensate Encode.xs and Decode.xs added a #define U8 U8,
just to signal to encode.h that this time it it going to link against
libperl.so.

I think the proper fix would be to use e.g. the PERL_H symbol instead
of U8 to signal that you are compiling the XS code. And then you can
get rid of the #define U8 U8 completely.

Cheers,
-Jan

On Mon, Apr 28, 2014 at 4​:03 PM, Dave Mitchell <davem@​iabyn.com> wrote​:

On Mon, Apr 28, 2014 at 10​:20​:52AM -0700, Steve Hay via RT wrote​:

Now fixed in blead by commit 080a704 using Dan's modified version of Daniel's patch.

Thanks to both (and to Jan for reporting it).

Unfortunately that's broken g++ builds.

Encode/encode.h contains​:

\#ifdef U8
/\* See comment at top of file for deviousness \*/

extern int do\_encode\(const encpage\_t \*enc\, const U8 \*src\, STRLEN \*slen\,
                     U8 \*dst\, STRLEN dlen\, STRLEN \*dout\, int approx\,
             const U8 \*term\, STRLEN tlen\);

extern void Encode\_DefineEncoding\(encode\_t \*enc\);

\#endif /\* U8 \*/

and U8 is apparently no longer defined(?), so do_encode() isn't getting
declared, so the build fails with​:

g++ -c -I./Encode -D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -ggdb -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -DVERSION=\"2.57\" -DXS_VERSION=\"2.57\" -fPIC "-I../.." Encode.c
Encode.xs​: In function 'SV* encode_method(PerlInterpreter*, const encode_t*, const encpage_t*, SV*, int, STRLEN*, SV*, int*, SV*)'​:
Encode.xs​:131​:29​: error​: 'do_encode' was not declared in this scope
trm, trmlen)) )
^

I have no idea what the correct fix is.

--
You're only as old as you look.

@p5pRT
Copy link
Author

p5pRT commented Apr 29, 2014

From @iabyn

On Tue, Apr 29, 2014 at 08​:22​:22AM +0100, Steve Hay wrote​:

Apologies for the g++ breakage. Compiling as C++ on Windows isn't easy
right now. (I looked at enabling a C++ build a while back but run into
some troubles [1], which I really must try to get round to resolving
after 5.20 is out.)

Anyway, if I understand Jan's comments correctly the proposal is to try this​:

diff --git a/cpan/Encode/Encode/encode.h b/cpan/Encode/Encode/encode.h
index af34ba2..52f54f7 100644
--- a/cpan/Encode/Encode/encode.h
+++ b/cpan/Encode/Encode/encode.h
@​@​ -1,7 +1,7 @​@​
#ifndef ENCODE_H
#define ENCODE_H

-#if !defined(U8) && !defined(U8TYPE)
+#ifndef PERL_H
/*
A tad devious this​:
perl normally has a #define for U8 - if that isn't present then we

That works for me (i.e. the VC6 build is still ok). Does it fix the g++ build?

I'm afraid not. I've pushed what I think is the correct fix as
9e9002e.

--
You're only as old as you look.

@p5pRT
Copy link
Author

p5pRT commented Apr 29, 2014

From @craigberry

On Tue, Apr 29, 2014 at 2​:22 AM, Steve Hay <steve.m.hay@​googlemail.com> wrote​:

Apologies for the g++ breakage. Compiling as C++ on Windows isn't easy
right now. (I looked at enabling a C++ build a while back but run into
some troubles [1], which I really must try to get round to resolving
after 5.20 is out.)

Anyway, if I understand Jan's comments correctly the proposal is to try this​:

diff --git a/cpan/Encode/Encode/encode.h b/cpan/Encode/Encode/encode.h
index af34ba2..52f54f7 100644
--- a/cpan/Encode/Encode/encode.h
+++ b/cpan/Encode/Encode/encode.h
@​@​ -1,7 +1,7 @​@​
#ifndef ENCODE_H
#define ENCODE_H

-#if !defined(U8) && !defined(U8TYPE)
+#ifndef PERL_H
/*
A tad devious this​:
perl normally has a #define for U8 - if that isn't present then we

That works for me (i.e. the VC6 build is still ok). Does it fix the g++ build?

Nope, still gives​:

Encode.xs​:131​:29​: error​: 'do_encode' was not declared in this scope
  trm, trmlen)) )
  ^
make[1]​: *** [Encode.o] Error 1

because do_encode is only declared when U8 is defined​:

#ifdef U8
/* See comment at top of file for deviousness */

extern int do_encode(const encpage_t *enc, const U8 *src, STRLEN *slen,
  U8 *dst, STRLEN dlen, STRLEN *dout, int approx,
  const U8 *term, STRLEN tlen);

extern void Encode_DefineEncoding(encode_t *enc);

#endif /* U8 */

Declaring U8 as a typedef will never make it be defined as a macro.
Maybe that's what's desired, in which case the reference to do_encode
in Encode.xs would also have to be ifdef'd out.

I have not been following this ticket and could not make heads or
tails out of what U8 has to do with the wrong number of parentheses in
Move, but what's happening now seems a simple case of referencing a
function while hiding its prototype. Either don't hide the prototype
or hide all uses of the function whenever you do hide it.

@p5pRT
Copy link
Author

p5pRT commented Apr 29, 2014

From @steve-m-hay

On 29 April 2014 12​:59, Dave Mitchell <davem@​iabyn.com> wrote​:

On Tue, Apr 29, 2014 at 08​:22​:22AM +0100, Steve Hay wrote​:

Apologies for the g++ breakage. Compiling as C++ on Windows isn't easy
right now. (I looked at enabling a C++ build a while back but run into
some troubles [1], which I really must try to get round to resolving
after 5.20 is out.)

Anyway, if I understand Jan's comments correctly the proposal is to try this​:

diff --git a/cpan/Encode/Encode/encode.h b/cpan/Encode/Encode/encode.h
index af34ba2..52f54f7 100644
--- a/cpan/Encode/Encode/encode.h
+++ b/cpan/Encode/Encode/encode.h
@​@​ -1,7 +1,7 @​@​
#ifndef ENCODE_H
#define ENCODE_H

-#if !defined(U8) && !defined(U8TYPE)
+#ifndef PERL_H
/*
A tad devious this​:
perl normally has a #define for U8 - if that isn't present then we

That works for me (i.e. the VC6 build is still ok). Does it fix the g++ build?

I'm afraid not. I've pushed what I think is the correct fix as
9e9002e.

Thanks. That's still all good with VC6. I'll update cpan #95130 to
give Dan (Kogai) a heads-up about what was actually done to resolve
this in the end.

@p5pRT
Copy link
Author

p5pRT commented Apr 29, 2014

From @bulk88

On Tue Apr 29 00​:22​:48 2014, shay wrote​:

Apologies for the g++ breakage. Compiling as C++ on Windows isn't easy
right now. (I looked at enabling a C++ build a while back but run into
some troubles [1], which I really must try to get round to resolving
after 5.20 is out.)

Core interp compiles on VC 2003 C++. Lots of breakage in /cpan though, so I've never pursued it.

There is also https://rt-archive.perl.org/perl5/Ticket/Display.html?id=120544 .

--
bulk88 ~ bulk88 at hotmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant