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

Custom warnings categories are disabled by any preceding no warnings 'category' #15482

Closed
p5pRT opened this issue Jul 28, 2016 · 7 comments
Closed

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Jul 28, 2016

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

Searchable as RT128765$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 28, 2016

From the.rob.dixon@gmail.com

Created by the.rob.dixon@gmail.com

With this module in file My/Warnings.pm

  package My​::Warnings;

  use warnings​::register;

  sub test {
  warnings​::warnif 'This is my warning';
  }

  1;

and this code in main.pl

  use strict;
  use feature 'switch';

  use warnings 'all';

  use My​::Warnings;

  print undef; # uninitialized warning

  given (1) { } # experimental warning

  My​::Warnings​::test(); # custom My​::Warnings warning

I get all three warnings output. However, changing it to

  use warnings 'all';
  no warnings 'experimental';

the custom category is disabled as well as the explicitly-mentioned
"experimental" category.

Also, a further reenabling

  use warnings 'all';
  no warnings 'experimental';
  use warnings 'experimental';

leaves the custom category disabled while the "experimental" category is
correctly reenabled.

Moving `use My​::Warnings;` to before any mention of the `warnings` pragma
fixes all of this, but I don't see that it should be necessary

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.24.0:

Configured by strawberry-perl at Tue May 10 21:33:22 2016.

Summary of my perl5 (revision 5 version 24 subversion 0) configuration:

  Platform:
    osname=MSWin32, osvers=6.3, archname=MSWin32-x64-multi-thread
    uname='Win32 strawberry-perl 5.24.0.1 #1 Tue May 10 21:30:49 2016 x64'
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE
 -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-fwrapv -fno-strict-aliasing -mms-bitfields',
    optimize='-s -O2',
    cppflags='-DWIN32'
    ccversion='', gccversion='4.9.2', gccosandvers=''
    intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=12345678,
doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16,
longdblkind=3
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='long
long', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='g++', ldflags ='-s -L"C:\strawberry\perl\lib\CORE"
-L"C:\strawberry\c\lib"'
    libpth=C:\strawberry\c\lib C:\strawberry\c\x86_64-w64-mingw32\lib
C:\strawberry\c\lib\gcc\x86_64-w64-mingw32\4.9.2
    libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32
-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr
-lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=, so=dll, useshrplib=true, libperl=libperl524.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=xs.dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-mdll -s -L"C:\strawberry\perl\lib\CORE"
-L"C:\strawberry\c\lib"'



@INC for perl 5.24.0:
    C:/Strawberry/perl/site/lib/MSWin32-x64-multi-thread
    C:/Strawberry/perl/site/lib
    C:/Strawberry/perl/vendor/lib
    C:/Strawberry/perl/lib
    .


Environment for perl 5.24.0:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\PHP\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files
(x86)\NVIDIA
Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Strawberry\perl\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\c\bin;C:\Python27\;C:\Python27\Scripts;E:\Perl\source\public;C:\ProgramData\chocolatey\bin;C:\Program
Files\Git\cmd;C:\ffmpeg\bin;C:\SQLite;C:\PHP;C:\tools\php;C:\rakudo\bin;C:\rakudo\share\perl6\site\bin
    PERL_BADLANG (unset)
    SHELL (unset)

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 28, 2016

From @cpansprout

On Thu Jul 28 10​:24​:51 2016, the.rob.dixon@​gmail.com wrote​:

This is a bug report for perl from the.rob.dixon@​gmail.com,
generated with the help of perlbug 1.40 running under perl 5.24.0.

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

With this module in file My/Warnings.pm

package My​::Warnings;

use warnings​::register;

sub test {
warnings​::warnif 'This is my warning';
}

1;

and this code in main.pl

use strict;
use feature 'switch';

use warnings 'all';

use My​::Warnings;

print undef; # uninitialized warning

given (1) { } # experimental warning

My​::Warnings​::test(); # custom My​::Warnings warning

I get all three warnings output. However, changing it to

use warnings 'all';
no warnings 'experimental';

the custom category is disabled as well as the explicitly-mentioned
"experimental" category.

Some time ago I suspected we had a problem like this, but I never got around to looking into it (or maybe I started and then forgot).

Internally perl uses a bitfield of warning categories and every time a category gets registered the bitfield grows. Additionally, it will skip the bitfield altogether for all warnings and no warnings, respectively.

In your original example, ‘use warnings 'all'’ uses the special ‘all warnings’ value, and everything works.

Adding ‘no warnings 'experimental'’ switches to bitfield-mode, and when the new category is registered, and the bitfield gets bigger, the new bit just ends up as 0 by default.

It seems that we need a bit that records the default value for newly-registered warnings. When a special value (such as ‘all warnings’) is converted into a bitfield, that new bit will get the appropriate value, as currently happens with categories already registered. When new categories are registered, they can copy that bit.

(BTW, I’m not volunteering to do any of this. But then again I might do it.)

--

Father Chrysostomos

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jul 28, 2016

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

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 17, 2017

From zefram@fysh.org

This was fixed by commit 006c1a1 in
Perl 5.27.6. This ticket can be closed now.

-zefram

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Dec 18, 2017

@iabyn - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jun 23, 2018

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release yesterday of Perl 5.28.0, this and 185 other issues have been
resolved.

Perl 5.28.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.28.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jun 23, 2018

@khwilliamson - Status changed from 'pending release' to 'resolved'

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