php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48708 Year can't be displayed on big endian system
Submitted: 2009-06-27 15:58 UTC Modified: 2009-07-07 01:00 UTC
Votes:4
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:0 (0.0%)
From: l_faillie at yahoo dot com Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 5.2.10 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
45 + 18 = ?
Subscribe to this entry?

 
 [2009-06-27 15:58 UTC] l_faillie at yahoo dot com
Description:
------------
In ext/date/php_date.c, years are stored as 64b integers but displayed using "%04ld" (32b integers). Only work on little endian system

Reproduce code:
---------------
echo date('Y y o');

"0000 09 2009".

Expected result:
----------------
"2009 09 2009"

Actual result:
--------------
"0000 09 2009"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-27 16:04 UTC] l_faillie at yahoo dot com
In ext/date/php_date.c, t->y (years) are stored as wide_int which is 'long long int' 64 bits but vararg or main/snprintf.c retrieve it as 'long int' (32 bits).

As consequence, on big endian system, only upper part is take in account and contains only 0. 

Tested on NetBSD / Sparc system but I guess reproducible on all big endian system (IBM, sparc, 68000, ...).

Bye the way, what is the need having 64b years which as been introduced w/ 5.2.10 ?

Bye

Laurent
 [2009-06-27 20:59 UTC] derick@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/
 [2009-06-28 20:00 UTC] l_faillie at yahoo dot com
Unfortunately, I'm not able to compile latest 5.3 due to GCC bug this time :
gcc: Internal error: Killed (program cc1)
Please submit a full bug report.
See <URL:http://www.netbsd.org/Misc/send-pr.html> for instructions.
gmake: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1

I'm planing to upgrade my system in coming weeks (during my holidays) implying a new GCC but it's not before at least 1 month.

As a workaround of this bug, I'm suggesting doing year display as integer as it was on 5.2.9.

Bye

Laurent
 [2009-06-28 22:33 UTC] scottmac@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

Derick linked to the wrong snapshot.

I've fixed this already.
 [2009-06-29 22:07 UTC] l_faillie at yahoo dot com
Unfortunately, no better luck :(

In file included from /web/temp/php5.2-200906282230/ext/date/lib/parse_tz.c:34:
/web/temp/php5.2-200906282230/ext/date/lib/timezonedb.h:5910: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.netbsd.org/Misc/send-pr.html> for instructions.
gmake: *** [ext/date/lib/parse_tz.lo] Error 1
 [2009-06-29 22:47 UTC] jani@php.net
How about you update your buggy compiler to something that actually 
works first?
 [2009-07-07 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 17:01:29 2024 UTC