Does anyone know where in the source code the real functionality behind use warnings resides?

That's in op.c for this particular warning; the relevant code (currently) starts at line 1948, with the check itself starting at line 1954:

1948                 if (ckWARN(WARN_VOID)) {
1949                     NV nv;
1950                     /* don't warn on optimised away booleans, eg
1951                      * use constant Foo, 5; Foo || print; */
1952                     if (cSVOPo->op_private & OPpCONST_SHORTCIRCUIT)
1953                         useless = NULL;
1954                     /* the constants 0 and 1 are permitted as they are
1955                        conventionally used as dummies in constructs like
1956                        1 while some_condition_with_side_effects;  */
1957                     else if (SvNIOK(sv) && ((nv = SvNV(sv)) == 0.0 || nv == 1.0))
1958                         useless = NULL;
1959                     else if (SvPOK(sv)) {
1960                         SV * const dsv = newSVpvs("");
1961                         useless_sv
1962                             = Perl_newSVpvf(aTHX_
1963                                             "a constant (%s)",
1964                                             pv_pretty(dsv, SvPVX_const(sv),
1965                                                       SvCUR(sv), 32, NULL, NULL,
1966                                                       PERL_PV_PRETTY_DUMP
1967                                                       | PERL_PV_ESCAPE_NOCLEAR
1968                                                       | PERL_PV_ESCAPE_UNI_DETECT));
1969                         SvREFCNT_dec_NN(dsv);
1970                     }
1971                     else if (SvOK(sv)) {
1972                         useless_sv = Perl_newSVpvf(aTHX_ "a constant (%"SVf")", SVfARG(sv));
1973                     }
1974                     else
1975                         useless = "a constant (undef)";
1976                 }

The special case for 0 and 1 was introduced in April 2001 in this commit (in Perforce rather than git back in those days, of course).


In reply to Re: warnings pragma anomaly by AppleFritter
in thread warnings pragma anomaly by Athanasius

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.