[LLVMbugs] [Bug 18644] New: Problem with tenary operator and errno: although condition is true it evaluates the else part
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jan 28 07:25:22 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=18644
Bug ID: 18644
Summary: Problem with tenary operator and errno: although
condition is true it evaluates the else part
Product: clang
Version: 3.4
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: christian at 2ndquadrant.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Hi,
while working on a patch for PostgreSQL I noticed that a error hint was not
displayed. The hint has been set via a ternary operator and a comparison of
errno:
ereport(FATAL,
(errmsg("could not map anonymous shared memory: %m"),
(errno == ENOMEM) ?
errhint("This error usually means that PostgreSQL's
request "
"for a shared memory segment exceeded available
memory "
"or swap space. To reduce the request size
(currently "
"%zu bytes), reduce PostgreSQL's shared memory
usage, "
"perhaps by reducing shared_buffers or "
"max_connections.",
*size) : 0));
In this case (checked with GDB) is errno == ENOMEM, but the hint wont appear.
The same code works fine with GCC.
clang version used:
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
gcc version used:
gcc (Gentoo 4.7.3-r1 p1.4, pie-0.5.5) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I wasn't able to create a small test case, but I uploaded my current working
tree so you can check it out:
http://www.defunced.de/postgres-working-tree.tgz
The compiler flags I used are in both cases (gcc and clang):
-O0 -g -W -Wall -ansi -pedantic -pipe -std=c99 -Wall -Wmissing-prototypes
-Wpointer-arith -Wdeclaration-after-statement -Wendif-labels
-Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv
-fexcess-precision=standard
I configured with this statement for clang:
CFLAGS="-O0 -g -W -Wall -ansi -pedantic -pipe -std=c99" CC=/usr/bin/clang
./configure --prefix=/home/ckruse/dev/postgres/
and with this for GCC:
CFLAGS="-O0 -g -W -Wall -ansi -pedantic -pipe -std=c99" ./configure
--prefix=/home/ckruse/dev/postgres/
Best regards,
--
Christian Kruse http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140128/294fe899/attachment.html>
More information about the llvm-bugs
mailing list