public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libitm/57855] New: passing unsafe function as transaction_safe function pointer does not generate error
@ 2013-07-09 1:05 spear at cse dot lehigh.edu
2013-07-09 1:08 ` [Bug libitm/57855] " spear at cse dot lehigh.edu
2013-07-12 13:10 ` patrick.marlier at gmail dot com
0 siblings, 2 replies; 3+ messages in thread
From: spear at cse dot lehigh.edu @ 2013-07-09 1:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57855
Bug ID: 57855
Summary: passing unsafe function as transaction_safe function
pointer does not generate error
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libitm
Assignee: unassigned at gcc dot gnu.org
Reporter: spear at cse dot lehigh.edu
The following code should be rejected, but is not:
#include <stdio.h>
// typedef of a function pointer that is transaction_safe
typedef void (*ADD_STAT)(const char *key, const int klen,
const char *val, const int vlen,
const void *cookie) __attribute__((transaction_safe));
// function that uses a transaction to call a function that is supposed to be
// safe
void bar(ADD_STAT f)
{
__transaction_atomic {
f(NULL, 0, NULL, 0, NULL);
}
}
// this function is not safe, and is not annotated as being safe
void my_func(const char *key, const int klen,
const char *val, const int vlen,
const void *cookie)
{
printf("Hello World\n");
}
// uh-oh! I can pass my_func to bar, and it doesn't break!
int main()
{
bar(my_func);
}
Compilation: gcc -std=gnu11 -DHAVE_CONFIG_H -DNDEBUG -g -O2 -pthread -fgnu-tm
-MD -MP -o demo demo.c
The issue here is that my_func is not transaction_safe, but when my_func is
passed to bar, which expects a transaction_safe function as its first
parameter, the compiler does not reject the code. It appears as though the
transaction_safe attribute in the typedef is being ignored when determining if
my_func is the correct type to be passed to bar, but not when determining if
my_func can be called from within bar's transaction.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libitm/57855] passing unsafe function as transaction_safe function pointer does not generate error
2013-07-09 1:05 [Bug libitm/57855] New: passing unsafe function as transaction_safe function pointer does not generate error spear at cse dot lehigh.edu
@ 2013-07-09 1:08 ` spear at cse dot lehigh.edu
2013-07-12 13:10 ` patrick.marlier at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: spear at cse dot lehigh.edu @ 2013-07-09 1:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57855
--- Comment #1 from Mike Spear <spear at cse dot lehigh.edu> ---
PS: error seems to have been around for a while, and is certainly present in
trunk revision 200806
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libitm/57855] passing unsafe function as transaction_safe function pointer does not generate error
2013-07-09 1:05 [Bug libitm/57855] New: passing unsafe function as transaction_safe function pointer does not generate error spear at cse dot lehigh.edu
2013-07-09 1:08 ` [Bug libitm/57855] " spear at cse dot lehigh.edu
@ 2013-07-12 13:10 ` patrick.marlier at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: patrick.marlier at gmail dot com @ 2013-07-12 13:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57855
Patrick Marlier <patrick.marlier at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |patrick.marlier at gmail dot com
--- Comment #2 from Patrick Marlier <patrick.marlier at gmail dot com> ---
There was a related discussion here:
http://gcc.gnu.org/ml/gcc-patches/2012-05/msg00598.html
Probably we can modify Dave's patch a bit.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-12 13:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-09 1:05 [Bug libitm/57855] New: passing unsafe function as transaction_safe function pointer does not generate error spear at cse dot lehigh.edu
2013-07-09 1:08 ` [Bug libitm/57855] " spear at cse dot lehigh.edu
2013-07-12 13:10 ` patrick.marlier at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).