Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Time-HiRes CPAN distribution.

Report information
The Basics
Id:
113856
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
RURBAN [...] cpan.org
Cc:
AdminCc:

BugTracker
Severity:
(no value)
Broken in:
(no value)
Fixed in:
(no value)

Attachments
0001-Time-Hires-Fix-declaration-after-statement-error-wit.patch



Subject: [PATCH] C90 declaration-after-statement error with darwin threads
This is invalid. HiRes.xs: In function 'darwin_time_init': HiRes.xs:773:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] struct timeval tv; ^ static int darwin_time_init() { #ifdef USE_ITHREADS MUTEX_LOCK(&darwin_time_mutex); #endif struct timeval tv; int success = 1; Patch attached. git am -p2, as I needed it in core. -- Reini Urban
Subject: 0001-Time-Hires-Fix-declaration-after-statement-error-wit.patch
From 7ef5ccaf84a5af9748342c434eefa39cbff63314 Mon Sep 17 00:00:00 2001 From: Reini Urban <rurban@cpanel.net> Date: Mon, 18 Apr 2016 09:38:13 +0200 Subject: [PATCH] Time-Hires: Fix declaration-after-statement error with darwin threads --- cpan/Time-HiRes/HiRes.xs | 4 ++-- diff --git cpan/Time-HiRes/HiRes.xs cpan/Time-HiRes/HiRes.xs index 8b8f25c..38ca0dc 100644 --- cpan/Time-HiRes/HiRes.xs +++ cpan/Time-HiRes/HiRes.xs @@ -767,11 +767,11 @@ static mach_timebase_info_data_t timebase_info; static struct timespec timespec_init; static int darwin_time_init() { + struct timeval tv; + int success = 1; #ifdef USE_ITHREADS MUTEX_LOCK(&darwin_time_mutex); #endif - struct timeval tv; - int success = 1; if (absolute_time_init == 0) { /* mach_absolute_time() cannot fail */ absolute_time_init = mach_absolute_time(); -- 2.8.1
From: jhi@iki.fi
Thanks. I was wondering how on earth has this been working at all, since I was pretty certain I tested this with threads in OS X. It turns out that the difference is between clang (the default cc in OS X) and gcc: clang (at least on OS X) doesn't seem to have a working -Werror=declaration-after-statement at all! $ cat das.c static int foo() { if (0) {} int i; return 0; } $ cc -Werror=declaration-after-statement -c das.c $ clang-mp-3.4 -Werror=declaration-after-statement -c das.c $ clang-mp-3.7 -Werror=declaration-after-statement -c das.c $ gcc-mp-4.4 -Werror=declaration-after-statement -c das.c das.c: In function 'foo': das.c:3: error: ISO C90 forbids mixed declarations and code $ das.c: In function 'foo': das.c:3:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] int i; ^ cc1: some warnings being treated as errors $ gcc-mp-5 -Werror=declaration-after-statement -c das.c das.c: In function 'foo': das.c:3:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] int i; ^ cc1: some warnings being treated as errors $ cc -v Apple LLVM version 7.3.0 (clang-703.0.29) ... $ clang-mp-3.7 -v clang version 3.7.1 (tags/RELEASE_371/final) ... $ clang-mp-3.4 -v clang version 3.4.2 (tags/RELEASE_34/dot2-final) ... The Apple 'cc' is clang 3.7. $ gcc-mp-4.4 -v ... gcc version 4.4.7 (MacPorts gcc44 4.4.7_10) $ gcc-mp-5 -v ... gcc version 5.3.0 (MacPorts gcc5 5.3.0_0)
From: jhi@iki.fi
Fixed in the just-released Time-HiRes 1.9733, and in bleadperl as http://perl5.git.perl.org/perl.git/commitdiff/de1003b4553058df412757f35324ef710bc68a2e
From: jhi@iki.fi
On Sat Apr 23 12:45:47 2016, jhi@iki.fi wrote:
Show quoted text
> Fixed in the just-released Time-HiRes 1.9733, and in bleadperl as > http://perl5.git.perl.org/perl.git/commitdiff/de1003b4553058df412757f35324ef710bc68a2e
FYI, reported the clang not doing its warning duty: https://llvm.org/bugs/show_bug.cgi?id=27493


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.